SettingsRow
@codeui/solid v0.3.0
Settings rows with a label, a description, and a control, grouped on islands.
When to use
Use SettingsRow for one preference in a settings dialog or panel: a title, a one-line description, and the control that changes it. Use SettingsGroup to put related rows under one heading on one island, as in a settings dialog's Interface, Colours, and Sidebar groups.
When to choose another component
Use a field's own label and description when the field stands alone in a form, as in TextField or Switch. Use OptionCard inside a wide row when a preview helps people choose. Settings navigation, search, and deep links belong to your app. The kit has no section component.
Live demo
import { NumberField, SegmentedControl, SegmentedControlItem, SettingsGroup, SettingsRow, Switch } from "@codeui/solid";
import "./settings-row.css";
export default function Basic() {
return <div class="settings-row-demo-pane">
<SettingsGroup title="Interface">
<SettingsRow label="Language" description="The language of the menus, labels and messages.">
{control => <div class="settings-row-demo-segments" style={{ "--segments": 3 }}>
<SegmentedControl {...control} defaultValue="en" size="sm" fluid>
<SegmentedControlItem value="it">Italian</SegmentedControlItem>
<SegmentedControlItem value="en">English</SegmentedControlItem>
<SegmentedControlItem value="de">German</SegmentedControlItem>
</SegmentedControl>
</div>}
</SettingsRow>
</SettingsGroup>
<SettingsGroup title="Sidebar">
<SettingsRow label="Visible" description="Show the sidebar next to the canvas." compactControl>
{control => <Switch {...control} defaultChecked />}
</SettingsRow>
<SettingsRow label="Padding" description="Space around the code.">
{control => <NumberField {...control} defaultValue={64} size="sm" />}
</SettingsRow>
</SettingsGroup>
</div>;
}SettingsGroup renders a heading and an island. Each SettingsRow puts its label and description on the left and its control on the right. Pass the control as a function child to receive the aria-labelledby and aria-describedby props that connect the row text to the control.
Anatomy
Editor
Applies to every snippet.
Tap a part to outline it in the demo.
- 01Row
settings-rowclasses.root - 02Label
settings-row-labelclasses.label - 03Description
settings-row-descriptionclasses.description - 04Details
settings-row-detailsclasses.details - 05Control
settings-row-controlclasses.control - 06Picture
settings-row-pictureclasses.picture - 07Marker
settings-row-markerclasses.marker - 08Group
settings-groupclasses.root - 09GroupTitle
settings-group-titleclasses.title - 10GroupDescription
settings-group-descriptionclasses.description - 11GroupContent
settings-group-contentclasses.content
| Export | Renders | classes key | data-cui | Role |
|---|---|---|---|---|
Row | div | root | settings-row | group in the ready row |
Label | span; label with for | label | settings-row-label | Row and control name |
Description | div | description | settings-row-description | Row and control description |
Details | div | details | settings-row-details | Extra content |
Control | div | control | settings-row-control | Control slot |
Picture | div | picture | settings-row-picture | Leading content |
Marker | span | marker | settings-row-marker | Badge after the label |
Group | section | root | settings-group | region when named |
GroupTitle | h3 | title | settings-group-title | Group heading |
GroupDescription | p | description | settings-group-description | Group description |
GroupContent | div | content | settings-group-content | The island |
Row keys go in SettingsRow classes. Group keys go in SettingsGroup classes. The ready row renders Picture, Description, Details, and Marker only when you supply them.
Variants
Inline and wide
import { OptionCardGroup, SettingsGroup, SettingsRow } from "@codeui/solid";
import "./settings-row.css";
export default function Wide() {
return <div class="settings-row-demo-pane">
<SettingsGroup title="Colours">
<SettingsRow label="Colour mode" description="Dark, light, or the same as your system." layout="wide">
{control => <OptionCardGroup aria-labelledby={control["aria-labelledby"]} defaultValue="dark" items={[
{ value: "dark", label: "Dark", description: "Dark surfaces", badge: "Default" },
{ value: "light", label: "Light", description: "Light surfaces" },
{ value: "system", label: "System", description: "Follow your device" },
]} />}
</SettingsRow>
</SettingsGroup>
</div>;
}layout="inline" is the default. The control sits on the right and the text column takes the rest. layout="wide" puts the control under the text at full width, for option cards, sliders, or any control wider than half the row.
Compact control
import { SegmentedControl, SegmentedControlItem, SettingsGroup, SettingsRow, Switch } from "@codeui/solid";
import "./settings-row.css";
export default function CompactControl() {
return <div class="settings-row-demo-pane">
<SettingsGroup title="Tabs">
<SettingsRow label="Show only active tab" description="The window shows the active tab alone." compactControl>
{control => <Switch {...control} />}
</SettingsRow>
<SettingsRow label="Panel side" description="The side of the canvas the sidebar sits on.">
{control => <div class="settings-row-demo-segments" style={{ "--segments": 2 }}>
<SegmentedControl {...control} defaultValue="left" size="sm" fluid>
<SegmentedControlItem value="left">Left</SegmentedControlItem>
<SegmentedControlItem value="right">Right</SegmentedControlItem>
</SegmentedControl>
</div>}
</SettingsRow>
</SettingsGroup>
</div>;
}Below 900px, inline rows put the control under the text. compactControl keeps a small control, such as a switch, on the right at every width. The breakpoint follows Inkstone §9.2 and uses the viewport width, not the row width.
Markers, pictures, and details
import { Badge, Button, SettingsGroup, SettingsRow, Switch } from "@codeui/solid";
import "./settings-row.css";
export default function Markers() {
return <div class="settings-row-demo-pane">
<SettingsGroup title="Local AI" description="Choices that are not the default yet.">
<SettingsRow label="Takumi" marker={<Badge>Experimental</Badge>} description="Use the experimental Takumi engine for image exports." compactControl>
{control => <Switch {...control} />}
</SettingsRow>
<SettingsRow
label="On-device model"
marker={<Badge tone="success">New</Badge>}
description="Chrome downloads it once, a few GB."
details="Chrome 148 or later, on a computer."
picture={<svg width="104" height="64" viewBox="0 0 104 64" aria-hidden="true"><rect width="104" height="64" rx="10" fill="var(--cui-surface-input)" /><path d="M20 22h64M20 34h40M20 46h52" stroke="var(--cui-text-muted)" stroke-width="4" /></svg>}
>
{control => <Button aria-describedby={control["aria-labelledby"]} variant="secondary" size="sm">Download</Button>}
</SettingsRow>
</SettingsGroup>
</div>;
}marker renders after the label, inside it, so a New or Experimental badge joins the control's accessible name. picture renders before the text and spans every text line. details renders under the description for content such as requirements, links, or progress.
A button keeps its visible text as its name. Do not spread the control props on it. Pass the row label as its description instead, as aria-describedby={control["aria-labelledby"]} does in this demo, so it reads as "Download, On-device model".
States
Disabled
import { SegmentedControl, SegmentedControlItem, SettingsGroup, SettingsRow, Switch } from "@codeui/solid";
import "./settings-row.css";
export default function Disabled() {
return <div class="settings-row-demo-pane">
<SettingsGroup title="Export">
<SettingsRow label="Transparent background" description="Not available for JPEG." compactControl>
{control => <Switch {...control} disabled />}
</SettingsRow>
<SettingsRow label="Format" description="The file type of the image.">
{control => <div class="settings-row-demo-segments" style={{ "--segments": 3 }}>
<SegmentedControl {...control} defaultValue="png" size="sm" disabled fluid>
<SegmentedControlItem value="png">PNG</SegmentedControlItem>
<SegmentedControlItem value="jpeg">JPEG</SegmentedControlItem>
<SegmentedControlItem value="svg">SVG</SegmentedControlItem>
</SegmentedControl>
</div>}
</SettingsRow>
</SettingsGroup>
</div>;
}The row has no disabled state of its own. Disable the control. The row text keeps its colour, so people can still read why the control is unavailable.
Labelled native input
import { SettingsGroup, SettingsRow, TextField } from "@codeui/solid";
import "./settings-row.css";
export default function NativeLabel() {
return <div class="settings-row-demo-pane">
<SettingsGroup title="Export">
<SettingsRow label="File name" description="Used when you save the image." controlId="export-file-name-input">
{control => <TextField {...control} id="export-file-name" defaultValue="snippet.png" size="sm" />}
</SettingsRow>
</SettingsGroup>
</div>;
}Set controlId to the id of one labelable input. The label then renders as <label for>, and clicking the title focuses the input. Composite controls, such as SegmentedControl or OptionCardGroup, take aria-labelledby instead. Do not wrap several controls in one label.
Long labels
import { SettingsGroup, SettingsRow, Switch } from "@codeui/solid";
import "./settings-row.css";
export default function LongLabels() {
return <div class="settings-row-demo-pane">
<SettingsGroup title="Ein sehr langer Gruppentitel, der in schmalen Bereichen umbricht">
<SettingsRow label="Bevorzugte Exportskalierung für hochauflösende Bildschirme" description="Die Skalierung bestimmt die Größe des exportierten Bildes in Pixeln, auch bei sehr langen Beschreibungen." compactControl>
{control => <Switch {...control} />}
</SettingsRow>
</SettingsGroup>
</div>;
}Labels and descriptions wrap, including unbroken text. The control keeps its width. Do not truncate labels.
Ready API
SettingsRow
Renders one row as a group named by its label and described by its description. Ids are <id>-label and <id>-description when you pass id, and generated otherwise.
Prop
Type
SettingsGroup
Renders a section named by its title and described by its description, with the rows on one island.
Prop
Type
createSettingsRowProps
Takes an accessor to { id?, controlId?, description? } and returns root, label, description, and control accessors. Spread them on the styled parts and the control. control() returns aria-labelledby and, when there is a description, aria-describedby. Join that value with the control's own description ids rather than replacing them. The helper is exported from @codeui/solid and @codeui/solid/settings/parts.
Styled parts API
Import the parts from @codeui/solid/settings/parts. These exports are direct named parts with no namespace alias and no Kobalte engine. Each part accepts class and the attributes of the element it renders.
import { Badge, createSettingsRowProps, Switch } from "@codeui/solid";
import * as Settings from "@codeui/solid/settings/parts";
import "./settings-row.css";
export default function Parts() {
const row = createSettingsRowProps(() => ({ id: "parts-autosave", description: "Save every change as you type." }));
return <div class="settings-row-demo-pane">
<Settings.Group aria-labelledby="parts-editor-title">
<Settings.GroupTitle id="parts-editor-title">Editor</Settings.GroupTitle>
<Settings.GroupContent>
<Settings.Row {...row.root()} compactControl>
<Settings.Label {...row.label()}>Autosave<Settings.Marker><Badge>New</Badge></Settings.Marker></Settings.Label>
<Settings.Description {...row.description()}>Save every change as you type.</Settings.Description>
<Settings.Control><Switch {...row.control()} defaultChecked /></Settings.Control>
</Settings.Row>
</Settings.GroupContent>
</Settings.Group>
</div>;
}Row
Renders the grid. layout sets data-layout and compactControl sets data-compact-control. Add role="group" and the ARIA props from createSettingsRowProps yourself.
Prop
Type
Label
Renders a span, or a label when for is set.
Prop
Type
Description
Prop
Type
Details
Prop
Type
Control
Holds the control on the right, or under the text in the wide and narrow layouts.
Prop
Type
Picture
Prop
Type
Marker
Place it inside Label.
Prop
Type
Group
Renders a section. Name it with aria-labelledby pointing at the title.
Prop
Type
GroupTitle
Renders an h3 by default. Use as to match the heading outline of your page.
Prop
Type
GroupDescription
Prop
Type
GroupContent
Renders the island. Rows touch inside it.
Prop
Type
Styles export
settingsRowStyles
settingsRowStyles and settingsGroupStyles are exported from @codeui/solid and @codeui/solid/settings/parts. Each anatomy key is a function that returns a class string. SettingsRowStyles and SettingsGroupStyles describe those functions. SettingsRowPart and SettingsGroupPart are the key unions, and SettingsRowClasses and SettingsGroupClasses are partial maps of keys to class names.
Row functions accept SettingsRowVariants, but ignore that argument. The wide layout depends on data-layout="wide", the compact control on data-compact-control, and the picture column on a direct settings-row-picture child. Use the styled parts to set those attributes.
Accessibility
Keyboard
The row and the group add no keyboard behavior and no tab stop. Tab moves through the controls in reading order. Each control keeps its own keys.
ARIA
The ready row renders role="group" with aria-labelledby on its label and aria-describedby on its description. A function child receives the same two props for the control, so a switch reads as "Visible, switch" with its description. SegmentedControl puts these props on its tab list. The ready group renders a section with aria-labelledby on its title, which exposes it as a region. A marker inside the label joins the accessible name, so keep it to one word.
Focus
Rows show no focus ring. The control shows its own. Clicking a label that has for focuses its input.
SSR notes
Rows, groups, labels, and the ARIA ids render on the server. Pass id to SettingsRow and SettingsGroup when the ids must match across server and client renders in different component trees. The function child runs once, during render.
Theming hooks
The row reads --cui-font-family-sans, --cui-font-size-sm, --cui-font-size-xs, --cui-font-weight-medium, --cui-font-line-height-compact, --cui-font-line-height-normal, --cui-text-default, and --cui-text-muted. It has a 56px minimum height. Spacing reads --cui-space-0-5, --cui-space-1-5, --cui-space-2, --cui-space-3, --cui-space-4, and --cui-space-6.
The group reads --cui-font-size-md, --cui-font-weight-semibold, and --cui-space-1 for its title. The island reads --cui-surface-canvas, --cui-radius-card, and --cui-space-1-5. surface-canvas is the island fill in Inkstone, so place groups on --cui-surface-panel. See Inkstone colour.
Inkstone specifies line height 1.3 for row titles and 1.4 for descriptions. The kit has no such tokens, so titles use compact (1.15, as CodeImage renders them) and descriptions use normal (1.5).
Composition examples
See Build settings for a complete settings dialog with navigation, groups, and rows.
Related
- Switch is the usual compact control.
- SegmentedControl chooses between two to four short options.
- OptionCard fits a wide row.