Vite + React
Set up SDAIA UI in a new or existing Vite + React project that uses TypeScript.
Before you start
- Node.js 20.19 or later (required by current versions of Vite).
- A Vite project created from the React + TypeScript template (
react-ts).
1. Create a project
Skip this step if you already have a Vite + React project.
npm create vite@latest my-app -- --template react-ts
Then install the packages:
cd my-app && npm install
2. Run init
Run init from the project root:
npx sdaia-ui@latest init
init detects Vite and asks four questions. The answers are pre-filled for your project, so you can press Enter for each one:
? Where should components be installed? › src/components/ui? Where should utilities (cn.ts) be installed? › src/lib? Which CSS file is your global stylesheet? › src/index.css? Which brand? (decides which font is installed) › Sdaia-DGA (default)
A new Vite project does not include Tailwind CSS, so init asks Install Tailwind CSS now?. Answer yes: components need Tailwind CSS v4. init also offers to remove the Vite starter styles from src/index.css (they fix the width of #root and override SDAIA styles); answer yes. It then adds the core styles to src/index.css, imports the fonts in src/main.tsx, and adds the @/ import alias to tsconfig.app.json, tsconfig.json and vite.config.ts. To skip every question, run init --yes.
3. Add a component
npx sdaia-ui@latest add button
The Button is copied to src/components/ui/Button.
4. Use it
import { Button } from '@/components/ui/Button';export default function App() {return <Button variant="primary">Get started</Button>;}
Start the dev server with npm run dev and open the address Vite prints.
Updating components
Installed components are your files, so new releases do not change them on their own. diff shows what changed for the components you installed, and update applies it (name the components, or use --all). Files you edited yourself are kept unless you pass --force; --dry-run previews the changes.
npx sdaia-ui@latest diff
npx sdaia-ui@latest update button
Arabic, dark mode and brands
Components follow the document direction. For Arabic, set lang="ar" and dir="rtl" on the <html> element in index.html, or pass dir="rtl" to a single component. For dark mode, toggle the theme-dark class on the <html> element: it switches both the design tokens and Tailwind dark: styles. A plain dark class works the same way. If you chose a brand other than Sdaia-DGA, add the class init prints (for example brand-spectrum) to the <html> element too.