Getting started
Theming
Every component takes its colors, corners, type and motion from a few CSS variables in tokens.css. Change them once and everything follows.
npx sinaui init adds the tokens to your project; see Installation.
Accent color
Sina UI is monochrome by default: the accent is the text ink. For color, set data-accent on <html> to blue, orange, lime, emerald, pink or sky, and mono on a part that should stay in ink. Primary buttons, checked controls, focus rings,
links, sliders and the first chart series all follow it. Set it on any container instead to color just
that part of a page.
<html data-accent="blue"> Each preset passes 4.5:1 as text on the page and under the text of a filled button, in light and
dark. Svelte's orange, #ff3e00, reads at only 3.5:1 on white, so in light mode the
orange preset takes a deeper step of it. For a color of your own, set --ui-accent and --ui-on-accent, with a light and a dark half (see Dark mode).
Corners
Every corner is square by default, an editorial look. Surfaces and controls round separately: --ui-radius shapes cards, menus and dialogs, --ui-radius-control buttons
and fields, and --ui-radius-pill tags, badges and tracks. For a softer look, set them
to 0.75rem, 0.5rem and 999px. Circles, like avatars and radio
buttons, stay round.
Size
Fields, selects, medium buttons and tabs share one height, --ui-control-h, and one
text size, --ui-control-font, so a form lines up at any size. For a compact
interface, set them inside @media (pointer: fine): touch screens keep 44px targets,
and iOS Safari zooms into any field with text under 16px. Small and large buttons follow --ui-control-h-sm and --ui-control-h-lg, button text --ui-button-font, and on touch screens every control is --ui-control-h-touch tall.
Dark mode
Every color is a light-dark() pair, so pages follow the reader's system setting. To
let people choose, set data-theme="light" or "dark" on <html>.
When you change a color, give both halves: light-dark(#4338ca, #a5b4fc). Check that
text on it reads at 4.5:1 in each.
Type
Components use --ui-font for text and --ui-font-mono for code, numbers and
small labels. The defaults are Mona Sans and Geist Mono; load them (both are free on Fontsource) or
point these at your own fonts.
Headings get their hierarchy from weight and width, not color: bold, and narrowed on Mona Sans's
width axis through --ui-heading-stretch. A font without a width axis ignores it.
Text inside components follows your page's font. tokens.css sets the page to --ui-font only when your app doesn't set its own. If it does (Tailwind sets one), the
components take your app's font. To use --ui-font everywhere, add html { font-family: var(--ui-font); } after your own CSS.
For a display face on titles (dialogs, drawers, cards, alerts, empty states), set --ui-font-heading. Left unset, titles follow the text around them.
With Tailwind
Components work alongside Tailwind's reset with nothing to configure: they set their own borders, spacing and list styles. Their CSS is scoped, so Tailwind classes in your markup don't change them.
All tokens
| Token | Used for |
|---|---|
--ui-bg | The page |
--ui-surface | Cards, menus, dialogs |
--ui-field-bg | Fields: inputs, selects, checkboxes, drop zones (white) |
--ui-fg | Text |
--ui-muted | Secondary text |
--ui-faint | The faintest fill: toolbar groups, idle stat tabs |
--ui-subtle | Quiet fills: tags, tracks, the current row |
--ui-hover | A step stronger than subtle |
--ui-line | Hairlines between things |
--ui-field-line | Borders of fields, buttons and cards |
--ui-control-line | Checkbox and radio outlines |
--ui-accent | Brand color: primary buttons, focus, selection |
--ui-on-accent | Text on the accent |
--ui-danger | Errors and destructive actions |
--ui-on-danger | Text on danger |
--ui-warning | Warnings |
--ui-backdrop | Behind dialogs |
--ui-ring | Focus ring color (the accent) |
--ui-ring-width | Focus ring thickness |
--ui-ring-offset | Gap between ring and control |
--ui-chart-1 | First chart series (the accent) |
--ui-chart-2 … 6 | The other chart series, in order |
--ui-radius | Corners of surfaces: cards, menus, dialogs (square by default) |
--ui-radius-control | Corners of controls: buttons, fields (square by default) |
--ui-radius-pill | Corners of tags, badges and tracks; 999px for pills |
--ui-control-h | Height of fields, selects, medium buttons and tabs |
--ui-control-h-sm | Height of small buttons |
--ui-control-h-xs | Height of extra-small buttons (24px with a mouse) |
--ui-control-h-lg | Height of large buttons |
--ui-control-h-touch | Height of every control on touch screens (44px or more) |
--ui-button-font | Text size of medium buttons |
--ui-control-font | Text size inside fields (16px or more on touch: iOS zooms smaller) |
--ui-shadow-card | Resting widgets and blocks: none by default |
--ui-card-line | Card: its outline and its inner sheet’s hairline (unset: --ui-line) |
--ui-shadow-overlay | Menus, popovers, dialogs |
--ui-font | Text |
--ui-font-size | Everyday text: labels, menus, lists (14px with a mouse) |
--ui-item-h | Height of a menu or list row (32px with a mouse) |
--ui-font-mono | Code and numbers |
--ui-font-heading | Titles of dialogs, cards, alerts; unset, they follow the text |
--ui-heading-weight | Headings: weight (700) |
--ui-heading-stretch | Headings: width on Mona Sans’s width axis (88%) |
--ui-heading-tracking | Headings: letter spacing |
--ui-label-font | Small labels and group titles: font (mono) |
--ui-label-case | Small labels: letter case (uppercase) |
--ui-label-tracking | Small labels: letter spacing |
--ui-sidebar-bg | Sidebar layout: the sidebar |
--ui-sidebar-line | Sidebar layout: its edges (a hairline by default) |
--ui-sidebar-current-bg | Sidebar layout: the current page |
--ui-sidebar-current-fg | Sidebar layout: the current page’s text |
--ui-sidebar-w | Sidebar layout: its open width |
--ui-button-pad-lg | Button: a large button’s side padding |
--ui-button-depth | Button: a raised edge the button presses into (0 is flat) |
--ui-sidebar-item-h | Sidebar layout: the height of each page row |
--ui-sidebar-font | Sidebar layout: the page rows’ text size |
--ui-sidebar-title-font | Sidebar layout: the group titles’ text size |
--ui-sidebar-title-family | Sidebar layout: the group titles’ font (the label font) |
--ui-sidebar-title-case | Sidebar layout: the group titles’ letter case (none or uppercase) |
--ui-sidebar-title-tracking | Sidebar layout: the group titles’ letter spacing |
--ui-sheet-width | Dialog: a side sheet’s width |
--ui-sheet-inset | Dialog: room a side sheet leaves beside it on narrow screens |
--ui-ease-out | Things arriving |
--ui-ease-in-out | Things moving on screen |
--ui-ease-drawer | Sheets and drawers |
--ui-dur-press | Press feedback |
--ui-dur | Most transitions |
--ui-dur-overlay | Overlays opening |