guides
Astro
Install and configure cnippet ui in an Astro project with the React integration.
cnippet ui components are React components, so Astro needs the React integration. Install them with the shadcn CLI.
Create a project
If you already have an Astro app, skip this step. This command sets up Tailwind CSS and the React integration:
The Tailwind starter loads the global stylesheet in src/layouts/main.astro. Keep that layout, or import @/styles/global.css in your pages.
For an existing app, add React with npx astro add react and make sure Tailwind CSS v4 is set up.
Edit tsconfig.json
Add the @/* alias so the CLI and your editor can resolve imports:
Run the CLI
This creates components.json, adds src/lib/utils.ts and sets up the CSS variables in src/styles/global.css.
Add the cnippet ui theme
This replaces the default colors with the cnippet ui tokens, including info, success and warning. See Colors.
Add components
Interactive components need a client directive
Astro renders React components to static HTML by default, with no JavaScript. That's fine for a Button that only shows text, but anything that opens, toggles or reacts to input (Dialog, Menu, Tabs, Select, Toast) must be hydrated.
Build the interactive part as its own React component and render it with a client:* directive:
Passing children from an .astro file into a hydrated component turns them into static HTML, so keep a component's parts (trigger, popup, items) inside the same React file.
Install everything at once
To add the full theme and every component in one command, run init with the cnippet ui style:
Next steps
- Set up Dark Mode and use the inline script from that guide in your layout's
<head>. - Browse all Components.