SelectionGroup
Controlled semantic owner for single- or multiple-selection ARCUI controls.
SelectionGroup coordinates selection-aware ARCUI children without owning hidden selection state. It is a semantic/context primitive wrapped in a normal native View.
Usage
Single selection
const [value, setValue] = useState<string | null>("balanced");
<SelectionGroup value={value} onValueChange={setValue}>
<Radio value="fast">Fast</Radio>
<Radio value="balanced">Balanced</Radio>
</SelectionGroup>;Single mode requires value. Use null when nothing is selected.
Multiple selection
const [values, setValues] = useState<string[]>(["motion"]);
<SelectionGroup multiple values={values} onValuesChange={setValues}>
<Checkbox value="motion">Motion</Checkbox>
<Checkbox value="accessibility">Accessibility</Checkbox>
</SelectionGroup>;values is normalized for membership checks so duplicate consumer values cannot create ambiguous selected state. The supplied array is never mutated.
Controlled ownership
SelectionGroup exposes one request callback and expects the parent to commit the requested state:
single: value -> onValueChange(nextValue)
multiple: values -> onValuesChange(nextValues)No hidden semantic selection is kept inside the group. If the parent does not update value/values, the rendered selection does not change.
Deselect behavior
allowDeselect exists only in single mode:
<SelectionGroup
value={value}
onValueChange={setValue}
allowDeselect
>
<Chip value="featured">Featured</Chip>
</SelectionGroup>When allowDeselect={false} (default), activating the currently selected value keeps it selected. With allowDeselect, the same action requests null.
This is useful for disclosure-like controls where an active item may be collapsed.
Compatible controls
SelectionGroup supplies ownership, but child semantics still define valid combinations:
| Control | Single group | Multiple group |
|---|---|---|
Radio | ✓ | — |
Checkbox | ✓ | ✓ |
Toggle | ✓ | ✓ |
selectable Chip | ✓ | ✓ |
Accordion | ✓ | ✓ through AccordionGroup |
Do not place a control into an incompatible mode merely because it has a value prop.
Runtime invariants
TypeScript models modes as a discriminated union, and ARCUI also validates malformed dynamic JavaScript at runtime.
Single mode:
requires value (null means no selection)
must not receive values
must not receive onValuesChangeMultiple mode:
requires values
must not receive value
must not receive onValueChange
must not receive allowDeselectThese are correctness invariants, so invalid combinations fail clearly rather than degrading cosmetically.
Layout and native View props
SelectionGroup renders a native View. Use style, testID, accessibility props, and other ViewProps normally:
<SelectionGroup
value={value}
onValueChange={setValue}
style={{ gap: 12 }}
testID="plan-group"
>
{children}
</SelectionGroup>ARCUI uses React 19 ref-as-prop and exposes the underlying View through ref.
Child callbacks
Selection-aware children may expose callbacks such as onCheckedChange / onSelectedChange. In grouped mode those callbacks are notifications around the group's requested semantic change; they are not a second state owner.
Keep the group callback as the place where application selection state is committed.
Testing
testID targets the group root directly; SelectionGroup itself does not create visual descendant test IDs. Test selected semantics through the child roles/states and use the root ID when layout or grouping needs a deterministic target.
For provider setup and react-native-arc-ui/testing, see Testing.
API Reference
Single Selection Group
Also inherits: Omit<ViewProps, "children" | "ref">
| Prop | Type | Default | Description |
|---|---|---|---|
| ref? | Ref<View> | — | Native SelectionGroup container ref. |
| children | ReactNode | required | — |
| multiple? | false | false | Single-selection mode. |
| value | TSelectionValue | null | required | Current selected value. SelectionGroup is controlled. The consumer owns this state. null represents no selection. |
| onValueChange? | (value: TSelectionValue | null) => void | — | Called when SelectionGroup requests a selected-value change. |
| allowDeselect? | boolean | false | Whether selecting the currently selected value requests clearing the selection. Useful for controls such as Accordion where the active item can be collapsed by selecting it again. |
Multiple Selection Group
Also inherits: Omit<ViewProps, "children" | "ref">
| Prop | Type | Default | Description |
|---|---|---|---|
| ref? | Ref<View> | — | Native SelectionGroup container ref. |
| children | ReactNode | required | — |
| multiple | true | required | Enables multiple-selection mode. |
| values | readonly TSelectionValue[] | required | Current selected values. SelectionGroup is controlled. The consumer owns this state. |
| onValuesChange? | (values: TSelectionValue[]) => void | — | Called when SelectionGroup requests a selected-values change. |
Generated from the ARCUI 1.1.x TypeScript source snapshot. Native inherited props remain available through the referenced React Native surface.
Motion
SelectionGroup itself has no visual animation layer and no SharedValue state. It only provides semantic ownership through React context. Individual controls own their own Reanimated visual transitions.
That separation is intentional: group semantics stay predictable while frame-level feedback remains local to the rendered control.
Performance
The group memoizes its semantic context functions/value and normalizes multiple values once per values change. Keep the controlled arrays stable where practical, but do not add custom memoization solely for SelectionGroup.
Accessibility
SelectionGroup does not invent an accessibility role for the container. Radio, checkbox, switch, chip/button, or disclosure semantics remain on the actual child controls. Native View accessibility props are still available when the application needs additional grouping context.
Theming
SelectionGroup has no visual token surface of its own. Theme, motion, color, typography, and press feedback belong to its children. This is an intentional design boundary rather than a missing token namespace.
Try it live
Explore SelectionGroup interactively in Expo Snack.
Open SelectionGroup in Expo Snack ↗