Astro
Initialize SIGMA-UI in a Astro project.
Create project (optional step)
If you don't have an Astro project yet, create it first. Here's an example using astro CLI:
npm create astro@latestAnd then add Vue to your Astro project:
npx astro add vueAnswer Yes to all the question prompted by the CLI when installing Vue.
This will install vue and @astrojs/vue as dependencies and automatically set them up in the astro.config.mjs file.
Install TypeScript
If you encounter the error Cannot find module 'typescript', install TypeScript as a dev dependency:
npm install -D typescriptAdd Tailwind CSS to your project
If you want to use Tailwind version of the SIGMA-UI components, and you don't already have Tailwind setup in your project, install the TailwindCSS module as well:
npx astro add tailwindThis will install tailwindcss and @astrojs/tailwind as dependencies and set them up in your astro.config.mjs file. It will also create a tailwind.config.mjs file with the needed configurations.
Check tsconfig
Make sure your tsconfig.json is configured correctly so that SIGMA-UI CLI commands can resolve alias paths and install components into your components dir:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
}
}Initialize SIGMA-UI
In your existing Astro project, run the following command to config SIGMA-UI (learn more in: CLI docs > init):
npx sigma-ui initAnd follow the steps in your terminal.
Import the globals.css file
Import the globals.css file in the src/index.astro file:
import '@/styles/globals.css'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.
export default defineConfig({
integrations: [
tailwind({
applyBaseStyles: false,
}),
],
})Add components
You can now start adding components to your project (learn more in: CLI docs > add):
npx sigma-ui add buttonThe command above will add the Button component to your project. You can then import and use it like this:
import { Button } from "@/components/ui/button"
...
<html lang="en">
<head>
<title>Astro</title>
</head>
<body>
<Button>Click me</Button>
</body>
</html>