Skip to Content
CodeUI

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

Interface

Language
The language of the menus, labels and messages.

Sidebar

Visible
Show the sidebar next to the canvas.
Padding
Space around the code.
settings-row/basic.tsx
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.

AutosaveNew
Save every change as you type.

Tap a part to outline it in the demo.

  1. 01Rowsettings-rowclasses.root
  2. 02Labelsettings-row-labelclasses.label
  3. 03Descriptionsettings-row-descriptionclasses.description
  4. 04Detailssettings-row-detailsclasses.details
  5. 05Controlsettings-row-controlclasses.control
  6. 06Picturesettings-row-pictureclasses.picture
  7. 07Markersettings-row-markerclasses.marker
  8. 08Groupsettings-groupclasses.root
  9. 09GroupTitlesettings-group-titleclasses.title
  10. 10GroupDescriptionsettings-group-descriptionclasses.description
  11. 11GroupContentsettings-group-contentclasses.content
ExportRendersclasses keydata-cuiRole
Rowdivrootsettings-rowgroup in the ready row
Labelspan; label with forlabelsettings-row-labelRow and control name
Descriptiondivdescriptionsettings-row-descriptionRow and control description
Detailsdivdetailssettings-row-detailsExtra content
Controldivcontrolsettings-row-controlControl slot
Picturedivpicturesettings-row-pictureLeading content
Markerspanmarkersettings-row-markerBadge after the label
Groupsectionrootsettings-groupregion when named
GroupTitleh3titlesettings-group-titleGroup heading
GroupDescriptionpdescriptionsettings-group-descriptionGroup description
GroupContentdivcontentsettings-group-contentThe 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

Colours

Colour mode
Dark, light, or the same as your system.
settings-row/wide.tsx
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

Tabs

Show only active tab
The window shows the active tab alone.
Panel side
The side of the canvas the sidebar sits on.
settings-row/compact-control.tsx
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

Local AI

Choices that are not the default yet.

TakumiExperimental
Use the experimental Takumi engine for image exports.
On-device modelNew
Chrome downloads it once, a few GB.
Chrome 148 or later, on a computer.
settings-row/markers.tsx
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

Export

Transparent background
Not available for JPEG.
Format
The file type of the image.
settings-row/disabled.tsx
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

Export

Used when you save the image.
settings-row/native-label.tsx
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

Ein sehr langer Gruppentitel, der in schmalen Bereichen umbricht

Bevorzugte Exportskalierung für hochauflösende Bildschirme
Die Skalierung bestimmt die Größe des exportierten Bildes in Pixeln, auch bei sehr langen Beschreibungen.
settings-row/long-labels.tsx
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.

Editor

AutosaveNew
Save every change as you type.
settings-row/parts.tsx
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.

On this page