The slabui CLI is in development. Commands, options and the registry format
may change before version 1.0.
A theme item has only CSS variables, but any item can bring its own (a table
with its colors, for example). slabui add writes them to your global CSS.
Where the variables go
The CSS variables of an item come in three groups:
| Group | Written to | Use for |
|---|---|---|
theme | @theme inline | Tailwind theme values that are not colors |
light | :root | Variables of the light mode |
dark | .dark | Variables of the dark mode |
Every light or dark value that is a color (oklch, hsl, rgb, #…) also
gets --color-<name>: var(--<name>) in @theme inline, so Tailwind classes like
bg-<name> work right away.
In the user's project
After npx slabui add theme-default, the css file from slabui.json contains:
@import "tailwindcss";
@custom-variant dark (&:is(.dark *));
@theme inline {
--radius-sm: calc(var(--radius) * 0.6);
--radius-lg: var(--radius);
--color-background: var(--background);
--color-foreground: var(--foreground);
}
:root {
--background: oklch(1 0 0);
--foreground: oklch(0.145 0 0);
--radius: 0.65rem;
}
.dark {
--background: oklch(0.145 0 0);
--foreground: oklch(0.985 0 0);
}The rest of the file is kept. Existing :root, .dark and @theme inline
blocks are reused; missing ones are created at the end.
Updates
update merges the variables one by one, comparing with the installed version:
| Situation | What happens |
|---|---|
| New variable | Added |
| Value not changed by the user | Updated to the new value |
| Value changed by the user | Kept, with a warning |
| Variable removed in the new version | Asks before removing; kept with --yes |
| Variable the user deleted | Not added back |
Edit the theme live
To change the theme in your running app and see every change right away, use the theme editor.