Chip
A compact chip in the button language (variants, tones, sizes, shapes) that toggles with a drawn check or acts as a plain button.
npx @swipeui/cli add chipWhen to use it
- A single filter toggle, such as Open now or Free delivery.
- Small tappable suggestions or quick actions with an icon, such as Share or Coffee near me.
- Compact choices in a row that should look like the app's buttons.
When not to use it
- A set of related filters. Chip group manages them together.
- Main actions. Use Button.
- Read-only labels or counts. Use Badge.
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- Adds
components/swipeui/ui/chip.tsxand 13 shared helpers. - Installs react-native-reanimated, uniwind, clsx, tailwind-merge, react-native-worklets, 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 { Chip } from '@/components/swipeui/ui/chip';
<Chip selected={vegan} onSelectedChange={setVegan}>Vegan</Chip>
<Chip icon={ShareIcon} tone="primary" onPress={share}>Share</Chip>Examples
The looks follow Button. At rest a chip is tinted and neutral; a chosen toggle is solid and primary:
<Chip variant="outline" tone="success" size="lg" shape="pill">Paid</Chip>
<Chip selected={open} onSelectedChange={setOpen} selectedVariant="tinted">Open now</Chip>API reference
| Prop | Type | Default | Description |
|---|---|---|---|
children | | — | The label. Strings are wrapped in |
icon? | | — | An icon before the label: a node, or a function given |
leading? | | — | 1.x name for |
trailing? | | — | Content after the label, such as a count. |
selected? | | — | Whether it is selected (controlled). Setting any selection prop makes the chip a toggle. |
defaultSelected? | | — | Whether it starts selected (uncontrolled toggle). |
onSelectedChange? | | — | Called with the new state when the user toggles it. |
onPress? | | — | Called on every press, toggle or not. |
onLongPress? | | — | Called on a long press (Chip group uses it for "only this"). |
variant? | | | The look at rest (and for plain chips): |
tone? | | | The colour family at rest. |
selectedVariant? | | | A selected toggle's look. |
selectedTone? | | | A selected toggle's colour family. |
size? | | |
|
shape? | | |
|
check? | | | A selected toggle draws a check on before its label, which slides over to make room. |
disabled? | | | No pressing. |
haptics? | | | Haptics: a switch, or per part ( |
motion? | | | Check, press and colour motion. |
accessibilityLabel? | | — | Overrides the label read by screen readers. |
accessibilityHint? | | — | Spoken hint, such as why it's disabled. |
className? | | — | Classes merged over the chip. |
style? | | — | Style escape hatch for the chip. |
testID? | | — | Identifier; the check appends |
Composition and behavior
- With
selected,defaultSelectedoronSelectedChangeit's a toggle: a tap gives it the selected look and draws a check on before the label, which slides over to make room. With anicon, the check takes the icon's place. - Without selection props it's a plain button that runs
onPress.onLongPresspasses through (Chip group uses it for "only this"). - Every size keeps a 44pt touch target. Toggle chips are toggle buttons with checked state (
aria-pressedon the web). - 1.x:
leadingstill works asicon. The default look is now the tinted fill with the preset's corners instead of a hairline border.
Chip settings
| Prop | Does | Default |
|---|---|---|
| selected / defaultSelected | Makes it a toggle (controlled or not) | not a toggle |
| variant / tone | Look at rest: tinted, solid, outline, ghost; neutral, primary, destructive, success | tinted, neutral |
| selectedVariant / selectedTone | Look when chosen | solid, primary |
| size | sm 28, md 32, lg 40pt | md |
| shape | preset corners or pill | preset |
| check | A drawn check when chosen | true |
| icon / trailing | Content before and after the label | none |
| disabled | No pressing | false |
| haptics | All, or { toggle, select } | on |
| motion | A local motion feel or override | the app's feel |
Behavior and gestures
- With `selected`, `defaultSelected` or `onSelectedChange`, a tap toggles it: the chip takes its selected look, a check draws on before the label and the label slides over to make room (`check`), with a selection tick.
- With an icon, the check takes the icon's place while selected.
- Without selection props it's a plain button: a light tap and `onPress`.
- `onPress` runs on every tap; `onLongPress` is there for groups (Chip group uses it for "only this").
- Disabled chips mute and ignore taps.
Accessibility
- Toggle chips are toggle buttons with checked state (`aria-pressed` on the web); plain chips are buttons.
- Every size keeps a 44pt touch target through extra touch area.
- Icons and the check are decorative; the label carries the meaning.
Motion
- Uses the
toggleandpressmotion roles, so it follows your app's feel. Passmotionto tune this one instance. - The check draws on and its slot opens on the toggle role, sliding the label; presses scale on the press role.
- Reduce Motion: the check appears without drawing and the slot jumps open.
Performance
- The check and slot animate on the UI thread; a chip re-renders only when its own state changes.
Notes for AI
- Pass selection props only when it should toggle. Looks follow Button: `variant` tinted, solid, outline or ghost and `tone` neutral, primary, destructive or success at rest; `selectedVariant` and `selectedTone` for the chosen state.
- `icon` takes a node or `({ color, size }) => node`; 1.x `leading` still works.
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.