Foundations
Color, typography, spacing, layout, shape, elevation, icons, motion and dark mode, the foundations every SUI component shares.
These foundations come from @workspace/ui/globals.css and the components themselves. Use the tokens and utilities named here instead of fixed values, so a page follows the theme, dark mode and the reader's preferences. Rules show each rule with a side-by-side example.
Color
Choose colors by role, never by hue. Each surface token has a matching foreground: bg-card with text-card-foreground, bg-primary with text-primary-foreground.
| Role | Tokens | Use |
|---|---|---|
| Canvas and surfaces | background, card, popover, secondary, muted | The page, grouped content, floating panels, secondary controls, quiet areas |
| Primary | primary, primary-foreground | The main action, filled selections such as tabs and checkboxes |
| Selection | accent, accent-foreground | Hovered and selected items, current links |
| Text | foreground, muted-foreground | Body text, descriptions and secondary labels |
| Lines and focus | border, input, ring | Separators, field fills, keyboard focus |
| Danger | destructive, destructive-foreground | Destructive actions and invalid input |
| Data | chart-1 to chart-5 | Chart series only |
- Keep one accent. Palettes such as
pineorrosechange the accent, focus and chart colors together while surfaces stay neutral; see Theming. - Never carry meaning by color alone. Pair status with text or an icon, and series with a legend or label.
- SUI has no success, warning or information tokens. Say the state in words and with an icon, or define application tokens beside the theme.
Typography
Font family
SUI uses each platform's own interface font, so text renders sharply and nothing has to download:
--font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC",
"Source Han Sans SC", sans-serif, "Apple Color Emoji", "Segoe UI Emoji",
"Segoe UI Symbol", "Noto Color Emoji";Latin text uses SF on Apple platforms, Segoe UI on Windows and Roboto on Android. Chinese falls back to PingFang, Hiragino Sans GB, Microsoft YaHei, then Noto or Source Han Sans; emoji use each system's color font.
- Never set
font-familyinside a component; everything reads--font-sans(headings use--font-heading, which points to it). - For a brand typeface, override
--font-sansin the app and keep the Chinese and emoji fallbacks after it.
Size and line height
Sizes and line heights come from Tailwind's scale. Keep to three to five sizes in one interface.
| Utility | Size / line height | Use | Weight |
|---|---|---|---|
text-xs | 12 / 16px | Captions, badges, labels in menus | font-normal or font-medium |
text-sm | 14 / 20px | Body, controls, table cells, data | font-normal |
text-base | 16 / 24px | Long-form reading, such as articles | font-normal |
text-base, text-lg | 16 / 24px, 18 / 28px | Titles of cards, dialogs, sheets, drawers and empty states | font-semibold |
text-lg, text-xl | 18 / 28px, 20 / 28px | Section headings | font-semibold |
text-2xl, text-3xl | 24 / 32px, 30 / 36px | Page titles | font-semibold |
- Content text is 14px everywhere: body, buttons, inputs, table cells. 16px and up is for headings and long reading. The one exception is a multi-line field: Textarea is 16px below
md, so iOS does not zoom the page when it takes focus. - Every title is
font-semibold, whatever its size. Short labels at 14px, such as the title of an alert, toast or list item, are emphasis and usefont-medium. - Keep the scale's line heights; don't tighten body text with
leading-noneorleading-tight.
Weight
Use three weights: 400 (font-normal) for text, 500 (font-medium) for emphasis, 600 (font-semibold) for headings. Never font-bold: Chinese strokes run together at 700, and the difference from 600 is not worth the noise.
Mixed Chinese and Latin text
- Put a space between Chinese and Latin letters or numbers: 「默认
h-9(36px)」, 「共 120 条」. - Never add tracking to Chinese, and leave Latin tracking as the font sets it.
- Write English headings in sentence case; Chinese has no case, so keep terms such as product names as they are.
- Align numbers in tables and statistics with
tabular-nums, and show inline code a step smaller than the text around it.
Text levels
Use two text colors: foreground for text people read and muted-foreground for descriptions, placeholders and secondary labels. Disabled controls fade through their own disabled state; don't express disabled, selected or invalid with a lighter color alone.
Spacing
Spacing follows Tailwind's 4px steps. Use few of them and use them consistently.
| Step | Value | Typical use |
|---|---|---|
1, 1.5, 2 | 4–8px | Icon and label, items in a toolbar, a label and its field |
3, 4 | 12–16px | Fields in a form, items in a list, small card padding (size="sm") |
6 | 24px | Card padding, groups inside a page |
8, 10, 12 | 32–48px | Sections of a page |
- Related things sit closer than unrelated ones: the space inside a group is smaller than the space around it.
- Prefer
gap-*on flex and grid containers over margins on children. - Adjust spacing optically around text, whose line box adds space above and below the glyphs.
Layout
Build application pages from the layouts: AppShell with a sidebar or top navigation, AppMain for the content area, and SectionLayout for pages with their own sections.
| Breakpoint | Width | What changes |
|---|---|---|
| Phone | below 768px (md) | The sidebar becomes a sheet, tables become cards, toolbars keep only search |
| Tablet | 768–1023px | The sidebar stays beside the content; section tabs are a row |
| Desktop | 1024px and up (lg) | Section tabs become a side column; full toolbars |
- Let the content area fill its space and scroll inside, so headers, toolbars and pagination stay in view (
AppMain fixed, DataTable'slayout="fill"). - Keep readable text under about 70 characters a line; forms rarely need more than
max-w-2xl. - Use logical properties (
ms-*,pe-*,start-*) so layouts mirror in right-to-left languages.
Shape
Every radius is a multiple of --radius (0.5rem by default), so changing it on the root or a container rescales every corner.
| Utility | Default | Typical use |
|---|---|---|
rounded-xl | 12px | Tables, tooltips, small nested surfaces |
rounded-2xl | 16px | Menu items and options inside a panel |
rounded-3xl | 24px | Inputs, selects, badges, popovers, menus |
rounded-4xl | 32px | Buttons (a pill at control height), cards, dialogs |
rounded-full | — | Avatars and other round elements |
Controls share one height so they line up in a row: h-9 (36px) by default, h-8 small and h-10 large.
When one rounded shape sits inside another within 8px, keep them concentric: outer radius = inner radius + padding.
Elevation
Elevation separates layers, not importance. Use as few levels as possible.
| Level | Surface | Use |
|---|---|---|
| Base | bg-background | The page |
| Raised | bg-card with SUI Card's shadow and ring | Grouped content on the page |
| Floating | bg-popover with a shadow | Menus, popovers, tooltips |
| Overlay | Dialog, Sheet, Drawer with a backdrop | Tasks that take over the page |
- Never combine a border with a drop shadow on the same surface. Floating surfaces (dialogs, sheets, drawers, popovers, toasts) pair their shadow with
ring-1 ring-foreground/5,ring-foreground/10in dark mode. - Never stack elevated cards inside each other. Group inside a card with spacing, a separator or a muted area.
- Separate a sticky header or footer from the scrolling content with a border, not a shadow.
- Glass is a material for floating controls over rich backgrounds. It turns back into opaque paint under reduced transparency, reduced motion and forced colors.
Icons
Icons come from Lucide at 16px (size-4) with a 2px stroke, the optical size of 14px text.
- Center an icon on the first line of its text; for wrapping text, wrap the icon in
h-lh flex items-center. - Decorative icons get
aria-hidden. An icon-only button needs an accessible name, and a tooltip showing it. - Use an icon to support a label, not to replace it, unless the meaning is universal (close, search, more).
Motion
Motion explains a change. It is short, it never blocks input, and it follows the reader's preference.
| Kind | Duration | Example |
|---|---|---|
| Small surface | 100ms | Popovers, menus, dialogs fading and scaling in |
| Backdrop | 150ms | The dimmed layer behind sheets and dialogs |
| Edge surface | 200ms | Sheets sliding from their side |
| Drag-driven surface | Follows the gesture | Drawers and bottom sheets settling after a swipe |
- Hover colors change immediately; transition transforms and shadows only.
- Overlays enter from where they belong: sheets from their edge, popovers from their trigger. A sheet that mounts already open still slides in.
- Keep content its full size while it collapses, and clip it, rather than squashing it.
- Under
prefers-reduced-motion, components drop movement and keep at most a fade.
Dark mode
Add dark to the root element. Every token has a dark value, so components need no dark-specific classes.
- Use tokens and the dark mode comes for free. A fixed color, such as
bg-whiteortext-gray-500, needs adark:counterpart, which is a sign it should be a token. - Check images and illustrations on both backgrounds; give transparent artwork a surface if it disappears.
- Follow the system setting by default and let people choose light, dark or system with ThemeToggle. Persisting the choice is up to the app.