Start by creating a new Astro project using create-astro
Configure your Astro project
You will be asked a few questions to configure your project:
Add Solid to your Astro project
Install Solid using the Astro CLI:
Add Tailwind CSS or UnoCSS to your project
Tailwind CSS
To install Tailwind CSS, use the Astro CLI:
UnoCSS
If you prefer UnoCSS, install UnoCSS:
Then create uno.config.ts in the root of your project:
Finally add UnoCSS integration to Astro config file:
Path Aliases
I’m use the @ alias to make it easier to import your components. This is how you can configure it:
Run the CLI
Run the shadcn-solid init command to setup your project:
Configure components.json
You will be asked a few questions to configure components.json:
Import the globals.css file
Import the globals.css file in the src/pages/index.astro file:
Update astro tailwind config
To prevent serving the Tailwind base styles twice, we need to tell Astro not to apply the base styles, since we already include them in our own globals.css file. To do this, set the applyBaseStyles config option for the tailwind plugin in astro.config.mjs to false.
Update tailwind.config.mjs
When running npx shadcn-ui@latest init, your tailwind config for content will be overwritten. To fix this, change the module.exports to export default and the content section with the code below to your tailwind.config.mjs file:
That’s it
You can now start adding components to your project.
You can then import shadcn componets in Astro like this: