ControlField

A label and description row around a switch, checkbox or stepper.

  • Composed
  • New in 0.1
import { ControlField, controlFieldPrimitive } from "nitro-ui-sdk/control-field";
HeroUI Native
ControlField
Expo UI
LabeledContent
  • ControlField example screen, light appearance
    Light
  • ControlField example screen, dark appearance
    Dark
On this page

ControlField lays out a name and optional description beside a native control. Use it for settings or short form rows that contain a switch, checkbox or stepper.

Anatomy

import { ControlField } from "nitro-ui-sdk/control-field";
import { Switch } from "nitro-ui-sdk/switch";
<ControlField.Root label="Reminders">
  <ControlField.Leading>
    <ControlField.Label />
    <ControlField.Description />
  </ControlField.Leading>
  <ControlField.Control>
    {(field) => <Switch.Root {...field}><Switch.Control /></Switch.Root>}
  </ControlField.Control>
</ControlField.Root>;
Part Description
Root Groups the two sides of the row.
Leading Optional touch target around the name and description.
Label Visible name.
Description Visible optional helper text.
Control Renders the trailing control with its accessible name, hint and disabled state.

Usage

import { ControlField } from "nitro-ui-sdk/control-field";
import { Switch, switchPrimitive } from "nitro-ui-sdk/switch";
const toggle = switchPrimitive.createApi();

<ControlField.Root label="Reminders" description="Receive a weekly email." controlApi={toggle}
  control={(field) => <Switch.Root {...field} api={toggle}><Switch.Control /></Switch.Root>} />;

Variants and sizes

The row uses one size with a 44 pt minimum leading touch target. Longer labels and descriptions wrap.

States

Disabled rows dim the text and stop forwarding row actions. The control render prop receives the same disabled value.

Controlled

Control ownership stays with the trailing control. Pass its value and onValueChange in the render function and attach its controller to both the control and the row.

Props

ControlField.Root

Prop Type Default Description
label string Required Localized name shared with the trailing control.
description string — Helper text passed to the control as its hint.
disabled boolean false Disable the row and its control.
control (props: ControlFieldControlProps) => ReactNode Required for default anatomy Render the trailing control and forward the provided props.
controlApi ControlFieldTarget — Controller exposing toggle or increment.
onPress (details: ActionDetails) => void — Optional row handler. Takes priority over the control API.
styles PartStyles<ControlFieldPart, ControlFieldVariant, ControlFieldSize, ControlFieldState> — Style resolvers keyed by part.
api Controller<ControlFieldActions> — Attach a controller created with the primitive.
agentId string — Identity for replacing a field in a reused view.
children ReactNode — Compound anatomy override.

ControlField.Leading

Prop Type Default Description
part ControlFieldPart — Override the style key for this part.
children ReactNode — Content to render inside this part.

ControlField.Label and ControlField.Description

Prop Type Default Description
part ControlFieldPart — Override the style key for this part.
children string Root text Visible text for this part.

ControlField.Control

Prop Type Default Description
part ControlFieldPart — Override the style key for this part.
children (props: ControlFieldControlProps) => ReactNode — Render the trailing control.

Controller API

import { ControlField, controlFieldPrimitive } from "nitro-ui-sdk/control-field";

const api = controlFieldPrimitive.createApi();
const field = <ControlField.Root label="Reminders" control={() => null} onPress={() => {}} api={api} />;

// Use api.current after the field mounts.
export { field, api };
Action Signature Result
press (source?: ActionSource) => ChangeStatus Invokes the row handler or forwards the target controller status.

Styles

import { ControlField } from "nitro-ui-sdk/control-field";

<ControlField.Root label="Reminders" control={() => null} styles={{ root: ({ tokens }) => ({ layout: { gap: tokens.spacing.lg } }) }} />;

Resolvers receive tokens, variant, size, and state. State includes disabled and actionable.

Accessibility

The row is an accessibility group. The trailing control receives the visible label and description, including text supplied to the compound parts. When onPress is set, the leading side is also an accessible button that invokes the handler. With controlApi, tapping the leading side forwards to the trailing control, which exposes the action to assistive technology.

Agent API

Action Arguments Notes
press None Available when the row has an onPress handler. For a row backed by controlApi, use the trailing control’s action, which settles against its owned value.

Platform notes

iOS Android
Implementation Renderer views with UIKit accessibility semantics. Renderer views with TalkBack semantics.
Verification Native iOS harness in the example app. Kotlin is written for Android. The Android NDK is unavailable on this machine, so no Android build was run.