React

Chip

A component that displays values selected or entered by users.

Available since@seed-design/react@0.1.4, @seed-design/css@0.1.4

Installation

npx @seed-design/cli@latest add ui:chip

Props

Chip.Button

Prop

Type

Chip.Toggle

Prop

Type

inputProps?React.InputHTMLAttributes<HTMLInputElement> | undefined
rootRef?React.Ref<HTMLLabelElement> | undefined
disabled?boolean | undefined
invalid?boolean | undefined
required?boolean | undefined
checked?boolean | undefined
defaultChecked?boolean | undefined
onCheckedChange?((checked: boolean) => void) | undefined
indeterminate?boolean | undefined

Chip.RadioRoot

Prop

Type

name?string | undefined
form?string | undefined
value?string | undefined
defaultValue?string | undefined
onValueChange?((value: string) => void) | undefined

Chip.RadioItem

Prop

Type

inputProps?React.InputHTMLAttributes<HTMLInputElement> | undefined
rootRef?React.Ref<HTMLLabelElement> | undefined
valuestring
disabled?boolean | undefined

Examples

Sizes

Small

Medium

Large

Variants

Solid

Outline Strong

Outline Weak

Prefix Icon

Suffix Icon

Icon Only

Prefix Avatar

Can be used with Avatar.

Listening to Value Changes

  • Chip.Toggle
    • You can detect toggle state changes using onCheckedChange.
    • If you need to use events, you can add event handlers directly to the internal <input> element through inputProps.
  • Chip.RadioRoot / Chip.RadioItem
    • You can detect radio button selection value changes using onValueChange of Chip.RadioRoot.
    • If you need to use events, you can add event handlers directly to the internal <input> element through inputProps of Chip.RadioItem.

Migrating from ActionChip/ControlChip

Replaces Action Chip and Control Chip.

ActionChip → Chip.Button

// Before
import { ActionChip } from "@seed-design/react";

<ActionChip size="medium">Label</ActionChip>

// After
import { Chip } from "@seed-design/react";

<Chip.Button size="medium" variant="solid">
  <Chip.Label>Label</Chip.Label>
</Chip.Button>

ControlChip → Chip.Toggle

// Before
import { ControlChip } from "@seed-design/react";

<ControlChip size="medium">Label</ControlChip>

// After
import { Chip } from "@seed-design/react";

<Chip.Toggle size="medium" variant="outlineStrong">
  <Chip.Label>Label</Chip.Label>
</Chip.Toggle>

Table of contents