Skip to Content
ARCUI

Toggle

Controlled switch-style boolean control with standalone or SelectionGroup ownership and token-safe geometry.

Toggle represents persistent on/off state with native switch semantics. Like other ARCUI selection controls, it supports standalone controlled state or SelectionGroup ownership.

Usage

import { Toggle } from "react-native-arc-ui";

const [enabled, setEnabled] = useState(true);

<Toggle checked={enabled} onCheckedChange={setEnabled}>
  Reduced motion
</Toggle>;

Standalone checked is controlled by the consumer.

SelectionGroup ownership

Toggle supports both single and multiple SelectionGroup modes because each toggle can represent one selectable value:

const [values, setValues] = useState<string[]>(["product"]);

<SelectionGroup multiple values={values} onValuesChange={setValues}>
  <Toggle value="product">Product updates</Toggle>
  <Toggle value="marketing">Marketing</Toggle>
</SelectionGroup>;

Inside a group, pass value instead of checked. onCheckedChange may be used as a child-level notification, but the group remains the semantic owner.

Content

Textual children receive ARCUI toggle typography and become the default accessible label when possible. Custom React content is rendered as supplied; provide an explicit accessibilityLabel when needed.

States

Disabled

<Toggle checked disabled>
  Locked setting
</Toggle>

Native disabled maps to the fully disabled visual and semantic state.

Inactive

<Toggle checked={false} active={false}>
  Temporarily inactive
</Toggle>

active={false} prevents interaction while retaining the dedicated inactive presentation.

Validation

<Toggle
  checked={accepted}
  onCheckedChange={setAccepted}
  error="Required"
>
  Accept policy
</Toggle>

A non-empty error enables the error modifier and renders a separate alert row.

Geometry

<Toggle
  checked={enabled}
  onCheckedChange={setEnabled}
  width={52}
  height={30}
  thumbSize={24}
/>

Per-instance geometry is cosmetic and degrades safely to tokens.sizings.toggle when malformed. Valid geometry must satisfy all of these invariants:

width > 0
height > 0
thumbSize > 0
width > height
thumbSize < height
thumbSize fits inside the track after border width is applied

The configured token geometry itself is an architecture invariant; invalid design-system geometry fails clearly instead of being silently normalized.

Press feedback

animation falls back to tokens.pressAnimation.type. Press callbacks from PressableProps remain available and are coordinated with ARCUI's internal press lifecycle.

<Toggle
  checked={enabled}
  onCheckedChange={setEnabled}
  animation="highlight"
>
  Analytics
</Toggle>

Native surface

Toggle inherits the safe PressableProps surface after ARCUI reserves switch role/checked/disabled semantics. textStyle affects textual child content only; normal style remains the root native style escape hatch.

Testing

With testID="motion-toggle":

motion-toggle
motion-toggle-track
motion-toggle-thumb
motion-toggle-label
motion-toggle-error-row
motion-toggle-error

For provider setup and the dedicated testing entrypoint, see Testing.

API Reference

Standalone Toggle

Also inherits: Omit< PressableProps, "children" | "role" | "accessibilityRole" | "aria-checked" | "aria-disabled" >

PropTypeDefaultDescription
children?ReactNode—Optional Toggle content. Textual content receives ARCUI typography and accessibility handling. Custom React content is rendered as-is.
onCheckedChange?(checked: boolean) => void—Called when the checked state is requested to change. Standalone: the consumer owns checked and should update it when appropriate. SelectionGroup: optional child-level notification after the group resolves an actual state change. SelectionGroup remains the state owner.
animation?TPressAnimation—Press feedback behavior. Falls back to tokens.pressAnimation.type.
active?booleantrueWhether the Toggle is active. Inactive keeps its dedicated visual state while preventing interaction.
width?number—Track width. Falls back to tokens.sizings.toggle.width.
height?number—Track height. Falls back to tokens.sizings.toggle.height.
thumbSize?number—Circular thumb diameter. Falls back to tokens.sizings.toggle.thumbSize.
error?string—Optional validation message. A non-empty value enables the Toggle error visual state.
textStyle?StyleProp<TextStyle>—Style applied only to textual Toggle content.
checkedbooleanrequiredStandalone semantic state. The consumer is the source of truth.

Grouped Toggle

Also inherits: Omit< PressableProps, "children" | "role" | "accessibilityRole" | "aria-checked" | "aria-disabled" >

PropTypeDefaultDescription
children?ReactNode—Optional Toggle content. Textual content receives ARCUI typography and accessibility handling. Custom React content is rendered as-is.
onCheckedChange?(checked: boolean) => void—Called when the checked state is requested to change. Standalone: the consumer owns checked and should update it when appropriate. SelectionGroup: optional child-level notification after the group resolves an actual state change. SelectionGroup remains the state owner.
animation?TPressAnimation—Press feedback behavior. Falls back to tokens.pressAnimation.type.
active?booleantrueWhether the Toggle is active. Inactive keeps its dedicated visual state while preventing interaction.
width?number—Track width. Falls back to tokens.sizings.toggle.width.
height?number—Track height. Falls back to tokens.sizings.toggle.height.
thumbSize?number—Circular thumb diameter. Falls back to tokens.sizings.toggle.thumbSize.
error?string—Optional validation message. A non-empty value enables the Toggle error visual state.
textStyle?StyleProp<TextStyle>—Style applied only to textual Toggle content.
valueTSelectionValuerequiredSelectionGroup identity. SelectionGroup owns the checked state.

Generated from the ARCUI 1.1.x TypeScript source snapshot. Native inherited props remain available through the referenced React Native surface.

The public union prevents standalone checked and grouped value ownership from being combined accidentally.

Motion

Thumb translation, track/thumb colors, modifier states, theme interpolation, and press feedback use Reanimated. Semantic checked state remains React/group-owned. Reduced Motion disables non-essential transitions while preserving the final checked state.

Performance

Toggle geometry is resolved during render, while continuous visual feedback stays on the UI thread. Do not mirror thumb position into application React state; own only the semantic boolean/value.

Accessibility

The root uses native switch semantics with accessibilityState.checked and disabled. Textual content becomes the default label when possible. The error row uses alert semantics and remains separate from the switch value.

Theming

Relevant token areas include:

colors.*.toggle
sizings.toggle
border.toggle
typography.toggle
toggleAnimations
pressAnimation
enteringExiting
animations

Try it live

Explore Toggle interactively in Expo Snack.

Open Toggle in Expo Snack ↗

On this page