Skip to content

web.css

A small, flat design system for UI SDK components. Square by default, built from a handful of tokens, with no animation and shadows only on things that float. It styles parts through their data-slot and state attributes, so the same stylesheet works in React, Vue, Svelte, Solid and web components.

Switch to Dark in the bar above to see every example in dark mode.

Install

Without a bundler, add two tags. The stylesheet follows the same release as the loader.

<script type="module" src="https://ui-sdk.dev/web.js"></script>
<link rel="stylesheet" href="https://ui-sdk.dev/web.css" />

With a bundler, import it once from core, next to your own CSS.

import "@ui-sdk/core/web.css"

Everything sits in @layer ui-sdk, so any style you write without a layer wins. Components inherit your page’s font. To use the system font, set font-family: var(--ui-font-sans) on body.

Principles

Flat Borders separate things. Shadows only appear on menus, lists, popovers and dialogs, which sit above the page.
Square Corners start at zero. One token rounds everything, and small parts scale from it.
Still Nothing animates. A state change is visible the moment it happens.
One height Every control is --ui-spacing × 8 tall, so inputs, selects and buttons line up on one row.
Yours to override A low cascade layer and plain custom properties. No classes to learn and nothing to unset.

Themes

A theme is a set of tokens. Set them on :root, or on any element to theme only what’s inside it.

:root {
  --ui-radius: 0.5rem;
  --ui-spacing: 0.28125rem;
  --ui-primary: light-dark(oklch(0.529 0.207 259.2), oklch(0.685 0.168 256));
}

Colors follow the page’s color-scheme. Set color-scheme: light dark to follow the system, or dark to force it.

Foundations

Color

Eleven roles, each with a light and a dark value. Components only use roles, never raw colors, so a theme changes them all at once.

Surfaces and text

--ui-background
--ui-foreground
--ui-muted
--ui-muted-foreground

Lines

--ui-border
--ui-input

Accent and status

--ui-primary
--ui-primary-foreground
--ui-destructive

Focus and overlay

--ui-ring
--ui-ring-border
--ui-overlay

Typography

One base size sets the scale. Titles sit 2px above it, labels and descriptions 1px below, and small text 2px below.

Role Sample Size
Title Delete this project?
Base Buttons, inputs, menus and body text.
Label Email address
Description We’ll send a confirmation link.
Small Group labels and shortcuts

Families

--ui-font-sans The quick brown fox jumps over the lazy dog
--ui-font-mono npm install @ui-sdk/web

Weight and leading

Three weights: 400 for text, 500 for controls and labels, 600 for titles. Running text uses --ui-line-height.

Spacing

A single unit, --ui-spacing. Every padding, gap and height is a multiple of it, so changing it changes the density of everything.

Step Used for Value
× 1 Popup inset
× 1.5 Label to control
× 2 Item padding, icon gap
× 3 Button padding
× 4 Between fields, popover padding
× 6 Dialog padding
× 8 Control height

Size

Controls share one height. Put any of them on a row and they line up, at every spacing and font size.

Radius

One token, --ui-radius, starting at zero. Small parts take half of it and floating surfaces take one and a half, so nested corners stay concentric. Switches and slider thumbs go fully round once the radius is above zero.

½
Checkbox, tracks
1
Controls
1½
Popups, dialogs
∞
Switch, thumb

Elevation

Two levels. The page is flat and separated by borders. Popups add --ui-shadow, and modals add --ui-overlay behind them.

Flat, 1px border
Popup, --ui-shadow

Focus

Keyboard focus draws a 4px --ui-ring right against the control, with no gap. Fields also turn their border to --ui-ring-border. Invalid fields use a red ring. Tab through any example to see it.

Focused field
Invalid field

Icons

The stylesheet draws the four icons components need, as CSS masks in currentColor, so there’s no icon library to load. Put your own <svg> in a part and the CSS icon steps aside.

--ui-icon-chevron Select, combobox, accordion, collapsible, navigation menu, submenus
--ui-icon-check Checkbox, selected items, checked menu items
--ui-icon-minus Indeterminate checkbox, number input decrement
--ui-icon-plus Number input increment

Motion

None. Popups appear and disappear at once, switches jump, and nothing fades. Components still set data-starting-style and data-ending-style, so you can add transitions in your own CSS.

Components

Accordion

Stacked sections that open one at a time, divided by lines. The chevron flips when open.

  • accordion-item
  • accordion-header
  • accordion-trigger
  • accordion-panel

Alert dialog

Asks for a decision before anything else can happen. Use the destructive button for the risky choice.

  • alert-dialog-backdrop
  • alert-dialog-content
  • alert-dialog-title
  • alert-dialog-description

Autocomplete

An input that suggests values but accepts anything.

  • autocomplete-input
  • autocomplete-content
  • autocomplete-item

Avatar

A picture with initials to fall back on while it loads or when it fails.

  • avatar
  • avatar-image
  • avatar-fallback

Button

Outlined by default. data-variant="solid" marks the main action and data-variant="destructive" one that deletes. A button with only an icon and an aria-label turns square.

  • button
  • [data-variant]
  • [data-disabled]

Calendar

A month in a bordered box. The selected day is filled, today is underlined, and days from other months fade.

  • calendar
  • calendar-previous
  • calendar-heading
  • calendar-next
  • calendar-grid
  • calendar-weekday
  • calendar-day
  • [data-selected]
  • [data-range-middle]
  • [data-today]

Checkbox

Filled with the primary color when checked. A label around it lines the box up with the first line of text, even when the text wraps.

  • checkbox
  • checkbox-indicator
  • [data-checked]
  • [data-indeterminate]

Collapsible

One section that shows and hides. The "Markup" toggle under every example on this page is one.

  • collapsible-trigger
  • collapsible-panel

Color picker

A saturation area, hue and alpha sliders on a checkerboard, and a row of presets. The selected preset gets an outline.

  • color-picker-area
  • color-picker-area-thumb
  • color-picker-slider
  • color-picker-slider-thumb
  • color-picker-swatch
  • color-picker-input
  • color-picker-swatch-item
  • color-picker-eye-dropper

Combobox

An input that filters a list. A trigger placed right after the input tucks into its end. A trigger on its own is a normal button.

  • combobox-label
  • combobox-input
  • combobox-trigger
  • combobox-content
  • combobox-item
  • combobox-empty

Command

A searchable list of actions in a bordered panel, with groups and shortcuts.

  • command
  • command-input
  • command-list
  • command-item
  • command-group-label
  • command-shortcut

Date input

Looks like an input. Each part of the date is its own segment, and the focused one is filled.

  • date-input
  • date-input-segment
  • [data-type]

Date picker

An input you can type a date into, with a calendar button inside its end. The calendar opens in a popup.

  • date-picker-input
  • date-picker-trigger
  • date-picker-clear
  • date-picker-content
  • date-picker-hint

Dialog

A focused task over a dimmed page. Title, description, content and actions.

  • dialog-backdrop
  • dialog-content
  • dialog-title
  • dialog-description
  • dialog-close

Drawer

A panel that slides in from an edge and can be dragged closed. Its outer corners follow the radius.

  • drawer-backdrop
  • drawer-viewport
  • drawer-content
  • drawer-title
  • drawer-description

Field

Wraps any control with a label, a description and an error. A fieldset groups fields under a legend.

  • field
  • field-label
  • field-description
  • field-error
  • field-set
  • field-legend
  • field-group

File input

A dashed drop zone that turns solid while you drag files over it, and a list of the files you added.

  • file-input-dropzone
  • file-input-trigger
  • file-input-list
  • file-input-item
  • file-input-item-remove
  • [data-dragging]

Form

Fields validate on submit. Press "Create account" with the form empty to see errors.

Hover card

A preview of what a link points to, for people who pause on it.

  • hover-card-trigger
  • hover-card-content

Image cropper

The area outside the crop is dimmed. Square handles sit on the corners and edges, and a grid shows while you drag.

  • image-cropper-viewport
  • image-cropper-image
  • image-cropper-selection
  • image-cropper-grid
  • image-cropper-handle

Input

Fills its field. Focus turns the border darker, and an invalid value turns it red.

  • input
  • [data-invalid]
  • [data-disabled]

Listbox

A list you pick from in place, with checks on what’s selected.

  • listbox
  • listbox-item
  • listbox-item-indicator

Meter

A measurement within a known range, like storage used.

  • meter-label
  • meter-value
  • meter-track
  • meter-indicator

Number input

A number between minus and plus buttons, joined into one control. The CSS draws both icons.

  • number-input-group
  • number-input-control
  • number-input-decrement
  • number-input-increment

OTP input

One box per character, joined into groups. The box you’re typing in gets the focus ring.

  • otp-input-group
  • otp-input-slot
  • otp-input-separator
  • [data-active]

Pagination

Plain page numbers. The current page gets a border, and gaps show an ellipsis.

  • pagination-list
  • pagination-item
  • pagination-link
  • pagination-previous
  • pagination-next
  • pagination-ellipsis
  • [aria-current]

Password input

An input with a button inside its end that shows or hides what you typed.

  • password-input
  • password-input-control
  • password-input-toggle
  • [data-visible]

Popover

Floating content with a title, a description and actions.

  • popover-trigger
  • popover-content
  • popover-title
  • popover-description
  • popover-close

Preferences

Preferences saves a choice, like list or grid, and has no look of its own. Style what you put inside it.

  • display: contents

Progress

How far a task has come. Without a value it’s indeterminate and shows a still stripe.

  • progress-label
  • progress-value
  • progress-track
  • progress-indicator
  • [data-indeterminate]

Radio

Radios stay round in every theme: the circle is how people tell one choice from many.

  • radio-group
  • radio
  • radio-indicator

Rating

Stars fill from the start in the primary color. Hovering shows what you’d pick in a lighter shade.

  • rating-item
  • rating-radio
  • [data-filled]
  • [data-highlighted]
  • --rating-fill

Resizable

Panels split by a 1px line. The line darkens while you hover or drag it, and has a wider hit area than it shows.

  • resizable
  • resizable-panel
  • resizable-handle
  • [data-dragging]

Scroll area

A bordered box with a thin scrollbar that shows while you hover or scroll.

  • scroll-area-viewport
  • scroll-area-content
  • scroll-area-scrollbar
  • scroll-area-thumb

Segmented control

Options on a muted track. The selected one sits on a raised, bordered indicator.

  • segmented-control-indicator
  • segmented-control-item
  • [data-checked]

Select

Looks like an input with a chevron. Its list is at least as wide as the trigger, and the selected item shows a check.

  • select-trigger
  • select-value
  • select-content
  • select-item
  • select-item-indicator

Separator

A 1px line in either direction. Next to text in a row it sits in the middle.

  • separator
  • [data-orientation]

Slider

A thin track with a square thumb that goes round in rounded themes. It fills its container, never narrower than 12rem.

  • slider
  • slider-control
  • slider-track
  • slider-indicator
  • slider-thumb
  • slider-value

Switch

For settings that apply at once. Square at zero radius, a pill above it.

  • switch
  • switch-thumb

Tabs

A line under the list, and a 2px underline on the selected tab.

  • tabs-list
  • tabs-tab
  • tabs-panel
  • [data-selected]
  • [data-orientation]

Text elements

A few plain elements get a matching look: links, code, keys and rules.

Textarea

An input for longer text. It starts five lines tall and resizes vertically.

  • textarea

Time input

The same segments as Date input, for hours, minutes and AM or PM.

  • time-input
  • time-input-segment
  • [data-type]

Toast

A floating card in a corner of the page with a title, a description and an optional action. Toasts stack without moving.

  • toast-region
  • toast-list
  • toast
  • toast-title
  • toast-description
  • toast-action
  • toast-close

Toggle

A button that stays pressed. Pressed shows a muted fill and a darker border.

  • toggle
  • [data-pressed]

Toggle group

Toggles joined into one control. Only the outer corners round.

  • toggle-group
  • toggle

Token input

A text area where mentions and tags become small bordered tokens. Type @ to try it.

  • token-input-editor
  • token-input-token
  • token-input-token-remove
  • [data-selected]

Toolbar

Borderless buttons and toggles in a bordered strip. A pressed toggle gets a border, and separators are 1px lines.

  • toolbar
  • toolbar-button
  • toolbar-separator
  • toolbar-group
  • toolbar-link

Tooltip

A short, inverted label on hover or keyboard focus. Flat, with no shadow.

  • tooltip-trigger
  • tooltip-content

Tree

Rows indent by level. Branches have a chevron that turns when they open, and the selected row is muted.

  • tree-item
  • tree-label
  • tree-indicator
  • tree-group
  • [data-selected]
  • [data-expanded]
  • --tree-level

Trigger menu

Suggestions that open as you type a character. Type @ to mention someone.

  • trigger-menu-input
  • trigger-menu-content
  • trigger-menu-item

More

Patterns

Components put together the way a product would use them.

Accounts

Team

Scheduling

Checkout

Uploads

Reviews

Settings

Workspace

Data

Messages