suiss/uim · React Native Component

Chip

A compact, selectable pill for filters and tags, with an optional icon and remove button.

Chip is an open-source mobile component from suiss/uim for React Native and Expo, with SwiftUI and Jetpack Compose versions built from the same design tokens. The @esuiss/uim CLI copies its source into your project, so you own the code.

iOS
Chip on iOS in light mode

Chip is a toggle rendered as a rounded Pressable. It switches between an unselected control background and a selected fill, and shrinks slightly while pressed. It has default and sm sizes, an optional leading icon, and an optional trailing remove button when onRemove is set.

ChipGroup manages selection for a set of chips: single selection by default, or several with multiple. It wraps chips onto new lines, or lays them out in a horizontal scroll view with scrollable.

Installation

$ pnpm dlx @esuiss/uim@latest add chip

The CLI also adds what it builds on: Icon, Text.

Manual

  1. Install the dependencies:
npx expo install class-variance-authority cn phosphor-react-native react-native-svg
  1. Add the pieces it builds on: Icon, Text, and the primitives components/primitives/toggle.tsx, components/primitives/toggle-group.tsx, components/primitives/use-render.tsx.

  2. Copy the source into components/ui/chip.tsx:

uniwind/components/ui/chip.tsx
import { cva } from "class-variance-authority"
import { cn } from "cn"
import { type Icon as PhosphorIcon, XIcon } from "phosphor-react-native"
import * as React from "react"
import { Pressable, ScrollView } from "react-native"
import {
  type ToggleChangeEventDetails,
  Toggle as TogglePrimitive,
  type ToggleState,
} from "@/components/primitives/toggle"
import { ToggleGroup as ToggleGroupPrimitive } from "@/components/primitives/toggle-group"
import { resolveClassName } from "@/components/primitives/use-render"
import { Icon, IconClassContext } from "@/components/ui/icon"
import { Text, TextClassContext } from "@/components/ui/text"

type ChipSize = "default" | "sm"
  1. Update the import paths to match your project.

Usage

import { Chip, ChipGroup } from "@/components/ui/chip"
<Chip>Open now</Chip>

Use selected with onSelectedChange, or defaultSelected, on a standalone chip. Inside a ChipGroup, give each chip a value and control the group with value, defaultValue and onValueChange (arrays of values).

The group's size is passed to every chip unless a chip sets its own. Use removeLabel to localize the remove button's label.

chipVariants is also exported if you need the classes elsewhere.

Examples

States

Unselected, selected and disabled chips.

iOS
Chip (states) on iOS in light mode

Sizes

The default and sm sizes.

iOS
Chip (sizes) on iOS in light mode

With icon

Chips with a leading icon.

iOS
Chip (with icon) on iOS in light mode

Removable

Chips with a remove button through onRemove.

iOS
Chip (removable) on iOS in light mode

Controlled

A chip controlled with selected and onSelectedChange.

iOS
Chip (controlled) on iOS in light mode

Group single

A group that allows one selected chip.

iOS
Chip (group single) on iOS in light mode

Group multiple

A group with multiple selection.

iOS
Chip (group multiple) on iOS in light mode

Group uncontrolled

A group using defaultValue.

iOS
Chip (group uncontrolled) on iOS in light mode

Group scrollable

A single scrolling row with scrollable.

iOS
Chip (group scrollable) on iOS in light mode

Group disabled

A disabled group.

iOS
Chip (group disabled) on iOS in light mode

API Reference

Chip

Selectable pill.

ExtendsChipProps

ChipGroup

Manages selection and layout for several chips.

ExtendsReact.ComponentProps<typeof ToggleGroupPrimitive>
PropType
About
Size passed to every chip.
Type
ChipSize
Default
"default"
About
Shows chips in a horizontal scroll view instead of wrapping.
Type
boolean
Default
false

Accessibility

  • A chip has the togglebutton role with checked state, or the radio role in a single-selection group.
  • A group has the radiogroup role for single selection and group for multiple.
  • With onRemove, the chip exposes a remove accessibility action, and the remove button has its own button role and label.

Notes

  • Uses bg-control, bg-control-selected and text-on-control-selected tokens with pressed and disabled states; light and dark follow the system appearance.