SwipeUI

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 chip
Variant
Preset
Material
Scheme
Feel
Real free component with a browser animation bridge. Native motion, haptics and materials need a device.

When 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.tsx and 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 install so versions match your SDK.

Usage

app/filters.tsx
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

PropTypeDefaultDescription
childrenReactNode—

The label. Strings are wrapped in Text.

icon?ChipIcon—

An icon before the label: a node, or a function given { color, size }. A ticked toggle shows its check here instead.

leading?ReactNode—

1.x name for icon (a node).

trailing?ReactNode—

Content after the label, such as a count.

selected?boolean—

Whether it is selected (controlled). Setting any selection prop makes the chip a toggle.

defaultSelected?boolean—

Whether it starts selected (uncontrolled toggle).

onSelectedChange?((selected: boolean) => void)—

Called with the new state when the user toggles it.

onPress?((event: GestureResponderEvent) => void)—

Called on every press, toggle or not.

onLongPress?((event: GestureResponderEvent) => void)—

Called on a long press (Chip group uses it for "only this").

variant?ChipVariant'tinted'

The look at rest (and for plain chips): tinted, solid, outline or ghost.

tone?ChipTone'neutral'

The colour family at rest.

selectedVariant?ChipVariant'solid'

A selected toggle's look.

selectedTone?ChipTone'primary'

A selected toggle's colour family.

size?ChipSize'md'

sm 28pt, md 32pt, lg 40pt, each with a 44pt touch target.

shape?ChipShape'preset'

preset (the preset's control corners, like Button) or pill (a capsule).

check?booleantrue

A selected toggle draws a check on before its label, which slides over to make room.

disabled?booleanfalse

No pressing.

haptics?boolean | SelectionHapticstrue

Haptics: a switch, or per part (toggle for a toggle, select for a plain press).

motion?MotionOverridethe app's feel

Check, press and colour motion.

accessibilityLabel?string—

Overrides the label read by screen readers.

accessibilityHint?string—

Spoken hint, such as why it's disabled.

className?string—

Classes merged over the chip.

style?StyleProp<ViewStyle>—

Style escape hatch for the chip.

testID?string—

Identifier; the check appends -check.

Composition and behavior

  • With selected, defaultSelected or onSelectedChange it'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 an icon, the check takes the icon's place.
  • Without selection props it's a plain button that runs onPress. onLongPress passes through (Chip group uses it for "only this").
  • Every size keeps a 44pt touch target. Toggle chips are toggle buttons with checked state (aria-pressed on the web).
  • 1.x: leading still works as icon. The default look is now the tinted fill with the preset's corners instead of a hairline border.

Chip settings

PropDoesDefault
selected / defaultSelectedMakes it a toggle (controlled or not)not a toggle
variant / toneLook at rest: tinted, solid, outline, ghost; neutral, primary, destructive, successtinted, neutral
selectedVariant / selectedToneLook when chosensolid, primary
sizesm 28, md 32, lg 40ptmd
shapepreset corners or pillpreset
checkA drawn check when chosentrue
icon / trailingContent before and after the labelnone
disabledNo pressingfalse
hapticsAll, or { toggle, select }on
motionA local motion feel or overridethe 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 toggle and press motion roles, so it follows your app's feel. Pass motion to 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 onSupported
Expo SDK 57Yes
Expo SDK 58Yes
React Native CLI (with Expo modules)Yes
Expo GoYes
iOSYes
AndroidYes

This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.

Related items