Chip group
Chips that wrap with gliding neighbours, fold behind "+N more" without hiding chosen ones, or scroll in one soft-edged row; single or multiple, with a limit and long-press "only this".
npx @swipeui/cli add chip-groupWhen to use it
- Filter rows above a list, such as cuisines, sizes or categories.
- Picking several interests during onboarding.
- Single-choice pills when a segmented control is too rigid.
- Choices that should wrap onto several lines on small screens.
When not to use it
- A handful of options that switch a view. Use Segmented control.
- Long lists of options. Use Multi-select.
- Free-form tags people type. Use Tag input.
Installation
Run this from your app's root. If SwipeUI isn't set up yet, run npx @swipeui/cli init first; it sets up Uniwind, the theme tokens and the cn helper.
npx @swipeui/cli add chip-group- Adds
components/swipeui/ui/chip-group.tsx,components/swipeui/ui/use-chip-group.tsand 14 shared helpers. - Installs react-native-reanimated, clsx, tailwind-merge, react-native-worklets, uniwind, expo-haptics, class-variance-authority, react-native-svg, react-native-gesture-handler. In Expo apps it uses
npx expo installso versions match your SDK.
Usage
import { ChipGroup } from '@/components/swipeui/ui/chip-group';
<ChipGroup
accessibilityLabel="Cuisines"
options={[
{ value: 'italian', label: 'Italian' },
{ value: 'japanese', label: 'Japanese' },
]}
/>;Examples
Fold long sets behind "+N more" (chosen chips stay visible) and allow at most three:
<ChipGroup accessibilityLabel="Cuisines" options={cuisines} maxVisible={5} max={3} />One scrolling row for categories, with soft edges in the card's colour:
<ChipGroup type="single" layout="scroll" options={categories} fadeClassName="bg-card" />API reference
ChipGroupProps
| Prop | Type | Default | Description |
|---|---|---|---|
options | | — | The chips, in order. |
value? | | — | The chosen values (controlled), in option order. |
defaultValue? | | | The values chosen at first (uncontrolled). |
onValueChange? | | — | Reports the chosen values, in option order. |
type? | | | One chip at a time, or several. |
selectionMode? | | — | 1.x name for |
clearable? | | | Single: a second tap on the chosen chip clears it. |
max? | | | Multiple: the most that can be chosen. An extra tap shakes, plays a limit haptic and is announced once. |
layout? | | |
|
maxVisible? | | | Wrap: fold chips past this many behind a "+N more" chip. Chosen chips always stay visible. |
soloOnLongPress? | | | ★ Multiple: long-press a chip to choose it alone, with an impact haptic. |
variant? | | | Chips at rest. |
tone? | | | Chips' colour at rest. |
selectedVariant? | | | Chosen chips' look. |
selectedTone? | | | Chosen chips' colour. |
size? | | | Chip size. |
shape? | | | Chip shape. |
check? | | | Chosen chips draw a check on. |
fadeClassName? | | | Scroll: the colour class of the soft edges; match the surface behind the row. |
disabled? | | | No choosing. |
haptics? | | | Haptics: a switch, or per part ( |
messages? | | | Built-in strings. |
motion? | | | Chip, layout and reveal motion. |
accessibilityLabel? | | — | Spoken group name. |
className? | | — | Root classes. |
style? | | — | Root style. |
testID? | | — | Root identifier; chips append |
Options are SelectionOptions from selection-core: value, label, icon (a node or ({ color, size }) => node), disabled and disabledReason.
Composition and behavior
- Chosen chips draw their check on and the label slides over; neighbours glide aside, even across lines, and the group's height follows.
maxVisiblefolds the rest behind "+N more". Chips chosen past the fold stay visible. Tapping it reveals the rest one after another; "Show less" folds them again.- ★
layout="scroll"keeps one row. Soft edges show where there's more, and choosing a chip near an edge scrolls it into view. - ★ In multiple mode, a long press keeps only that chip (announced as "Only Italian"). Every chip can still be tapped one at a time.
maxrefuses an extra pick: the chip shakes once, a warning haptic plays and the limit is announced.- 1.x:
selectionModestill works (single lets a second tap clear, likeclearable).
Chip group settings
| Prop | Does | Default |
|---|---|---|
| type | single or multiple (1.x selectionMode) | multiple |
| clearable | Single: a second tap clears | false |
| max | The most that can be chosen | unlimited |
| layout | wrap or ★ scroll | wrap |
| maxVisible | Fold the rest behind "+N more" | all |
| soloOnLongPress | ★ Long-press for "only this" | true |
| variant / tone / selectedVariant / selectedTone | Chip looks, as Chip | tinted, neutral, solid, primary |
| size / shape / check | Chip size, corners and check | md, preset, true |
| fadeClassName | Scroll edges' surface colour | bg-background |
| disabled | No choosing | false |
| haptics | All, or { toggle, select, limit } | on |
| messages | "+n more", "Show less", "Only …", the limit | English |
Behavior and gestures
- Tap chips to choose or unchoose them; values come back in option order. A chosen chip draws its check on and its neighbours glide aside, even across lines.
- `type="single"`: choosing a chip replaces the last; with `clearable`, a second tap clears it.
- `maxVisible` folds the rest behind "+N more"; chosen chips past the fold stay visible. Tapping it reveals the rest with a stagger and "Show less" folds them again.
- ★ `layout="scroll"`: one row with soft edges where there's more, scrolling the chosen chip into view.
- ★ Multiple: long-press a chip to choose it alone, with an impact haptic (`soloOnLongPress`).
- `max` refuses an extra pick: the chip shakes, a warning haptic plays and "You can choose up to n" is announced.
Accessibility
- Each chip is a toggle button with checked state; a disabled chip speaks its `disabledReason` (or Unavailable) as the hint. Name the set with `accessibilityLabel`, such as "Cuisines".
- Long-press "only this" is announced ("Only Italian"); every chip can still be tapped one by one.
- Chips keep 44pt touch targets; the more chip is a button.
Motion
- Uses the
toggle,layout,listandpressmotion roles, so it follows your app's feel. Passmotionto tune this one instance. - Neighbours and the group's height glide on the layout spring; revealed chips fade in one after another on the list role; checks draw on the toggle role.
- Reduce Motion: no gliding or stagger (chips appear in place), checks appear without drawing, and the scroll jumps.
Performance
- Only changed chips re-render; scroll offsets are tracked without re-running the scroll-into-view.
Notes for AI
- Value is always an array. Use `type="single"` for one choice (1.x `selectionMode` still works and lets a second tap clear).
- Options are `SelectionOption`s (`icon` takes a node or a render function, `disabledReason`). Chip looks pass through: `variant`, `tone`, `selectedVariant`, `selectedTone`, `size`, `shape`, `check`.
Compatibility
| Runs on | Supported |
|---|---|
| Expo SDK 57 | Yes |
| Expo SDK 58 | Yes |
| React Native CLI (with Expo modules) | Yes |
| Expo Go | Yes |
| iOS | Yes |
| Android | Yes |
This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.