GitHub

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.

RoleTokensUse
Canvas and surfacesbackground, card, popover, secondary, mutedThe page, grouped content, floating panels, secondary controls, quiet areas
Primaryprimary, primary-foregroundThe main action, filled selections such as tabs and checkboxes
Selectionaccent, accent-foregroundHovered and selected items, current links
Textforeground, muted-foregroundBody text, descriptions and secondary labels
Lines and focusborder, input, ringSeparators, field fills, keyboard focus
Dangerdestructive, destructive-foregroundDestructive actions and invalid input
Datachart-1 to chart-5Chart series only
  • Keep one accent. Palettes such as pine or rose change 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-family inside a component; everything reads --font-sans (headings use --font-heading, which points to it).
  • For a brand typeface, override --font-sans in 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.

UtilitySize / line heightUseWeight
text-xs12 / 16pxCaptions, badges, labels in menusfont-normal or font-medium
text-sm14 / 20pxBody, controls, table cells, datafont-normal
text-base16 / 24pxLong-form reading, such as articlesfont-normal
text-base, text-lg16 / 24px, 18 / 28pxTitles of cards, dialogs, sheets, drawers and empty statesfont-semibold
text-lg, text-xl18 / 28px, 20 / 28pxSection headingsfont-semibold
text-2xl, text-3xl24 / 32px, 30 / 36pxPage titlesfont-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 use font-medium.
  • Keep the scale's line heights; don't tighten body text with leading-none or leading-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.

StepValueTypical use
1, 1.5, 24–8pxIcon and label, items in a toolbar, a label and its field
3, 412–16pxFields in a form, items in a list, small card padding (size="sm")
624pxCard padding, groups inside a page
8, 10, 1232–48pxSections 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.

BreakpointWidthWhat changes
Phonebelow 768px (md)The sidebar becomes a sheet, tables become cards, toolbars keep only search
Tablet768–1023pxThe sidebar stays beside the content; section tabs are a row
Desktop1024px 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's layout="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.

UtilityDefaultTypical use
rounded-xl12pxTables, tooltips, small nested surfaces
rounded-2xl16pxMenu items and options inside a panel
rounded-3xl24pxInputs, selects, badges, popovers, menus
rounded-4xl32pxButtons (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.

LevelSurfaceUse
Basebg-backgroundThe page
Raisedbg-card with SUI Card's shadow and ringGrouped content on the page
Floatingbg-popover with a shadowMenus, popovers, tooltips
OverlayDialog, Sheet, Drawer with a backdropTasks 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/10 in 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.

KindDurationExample
Small surface100msPopovers, menus, dialogs fading and scaling in
Backdrop150msThe dimmed layer behind sheets and dialogs
Edge surface200msSheets sliding from their side
Drag-driven surfaceFollows the gestureDrawers 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-white or text-gray-500, needs a dark: 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.