Chip

A selectable pill. Selecting it tints it and slides a tick in at the front while the pill grows; an optional close button removes it. Inputs.

Open playground

About

Chip is a React component in the Inputs category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { Chip } from "@ashutoshswamy/smoui" and set icon, onRemove, label among its 7 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { Chip } from "@ashutoshswamy/smoui";

<Chip label="Design" defaultSelected onChange={(selected) => console.log(selected)} />

Props 7

icon

Leading icon, replaced by a tick when selected.

IconName
onRemove

Adds a close button.

() => void
label

Visible text and accessible name.

string
selected / defaultSelected

Controlled or initial selection.

boolean
onChange

Called when pressed.

(selected: boolean) => void
disabled

Disables selection.

booleandefault false
className

Class on the button.

string