Label
Names any control by its htmlFor, also a slider or a radio group; a press on it moves focus there
Preview
Use
The code of the preview above
import { ChipButton, Label, Row, Stack } from '@/components/ui';
<Stack gap={2}>
<Label id="open-days">Open on</Label>
<Row gap={1} role="group" aria-labelledby="open-days">
{['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'].map((day, i) => (
<ChipButton key={day} defaultPressed={i < 5}>{day}</ChipButton>
))}
</Row>
</Stack>Options
| Option | Type | What it does |
|---|---|---|
className | string | More classes on the outer element, for layout around it (margins, grid placement), not to restyle it. |
It also takes the 283 attributes of the element or UI SDK part it draws: className, aria-label, events and the rest.
Without React
With the CSS in parts (/ui/css/), it needs these, besides the ones every page loads:
components/fields.csscomponents/checkbox-radio.csscomponents/switch.csscomponents/resizable-panels.csscomponents/input-group.csscomponents/choice-cards.csscomponents/calendar.cssHelpers: states, do and don’t
A label over a group of controls that is not one field (Field labels a single field).
Hooks and functions the components are made of, passed on so a project uses the same ones: keyboard shortcuts, options loaded while typing, search matching, saved preferences, screen-reader announcements, smooth sizes, the theme.
Do
- Use
useShortcutfor app-wide keys, and show the key withformatShortcutso it reads right on each computer. - Use
announce()to tell a screen reader what changed when nothing visible takes focus ("3 results").
Don't
- Don't turn off the smooth sizes
Toasterstarts; boxes would jump when their content changes.