Chip

Chip groups a compact label with an optional main action and removal button.

tsx
import { Chip } from '@/components/ui/wideset/chip/Chip';

<Chip>
  <Chip.Action>
    <Chip.Label>Remote only</Chip.Label>
  </Chip.Action>
  <Chip.IconButton aria-label="Remove Remote only filter" />
</Chip>

Installation

pnpm dlx wideset add chip

Copies the component and any Wideset components it uses into your project.

Examples

Variants

Primary gives the chip brand emphasis, for selected filters and values the user just applied. Secondary is quieter, for suggestions and supporting metadata.

tsx
import { Chip } from '@/components/ui/wideset/chip/Chip';

export default function ChipVariants() {
  return (
    <div className="gap-ws-12 flex flex-wrap items-center">
      <Chip variant="primary">
        <Chip.Label>Remote only</Chip.Label>
      </Chip>
      <Chip variant="secondary">
        <Chip.Label>Full time</Chip.Label>
      </Chip>
    </div>
  );
}

Styles

Filled reads as selected and carries more weight; border stays light, for rows of options in dense layouts. Mixing them in one row is how you show which options are on.

tsx
import { Chip } from '@/components/ui/wideset/chip/Chip';

export default function ChipStyles() {
  return (
    <div className="gap-ws-12 flex flex-wrap items-center">
      <Chip style="filled">
        <Chip.Action>
          <Chip.Label>Design</Chip.Label>
        </Chip.Action>
      </Chip>
      <Chip style="border">
        <Chip.Action>
          <Chip.Label>Engineering</Chip.Label>
        </Chip.Action>
      </Chip>
    </div>
  );
}

Sizes

Medium is the default. Small fits dense filter bars and table cells; large gives the chip more presence and a bigger hit area on touch screens. Chips in one row share a size.

tsx
import { Chip } from '@/components/ui/wideset/chip/Chip';

export default function ChipSizes() {
  return (
    <div className="gap-ws-12 flex flex-wrap items-center">
      {(['sm', 'md', 'lg'] as const).map((size) => (
        <Chip key={size} size={size}>
          <Chip.Action>
            <Chip.Label>Remote only</Chip.Label>
          </Chip.Action>
        </Chip>
      ))}
    </div>
  );
}

Icons

Leading icons are decorative. Action and IconButton call consumer handlers independently: this example applies a city through Action and removes values through IconButton. The example owns the list and moves focus to Reset examples after removal.

tsx
import { RiMapPinLine } from '@remixicon/react';
import { Button } from '@/components/ui/wideset/button/Button';
import { Chip } from '@/components/ui/wideset/chip/Chip';
import { useRef, useState } from 'react';

export default function ChipIcons() {
  const [cities, setCities] = useState(['Warsaw', 'Berlin']);
  const [selectedCity, setSelectedCity] = useState<string | null>(null);
  const resetRef = useRef<HTMLButtonElement>(null);
  const removeCity = (city: string) => {
    setCities((current) => current.filter((value) => value !== city));
    setSelectedCity((current) => (current === city ? null : current));
    resetRef.current?.focus();
  };

  return (
    <div className="gap-ws-5 flex flex-col items-start">
      <div className="gap-ws-5 flex flex-wrap items-center">
        <Chip variant="secondary">
          <Chip.Action onClick={() => setSelectedCity('Prague')}>
            <Chip.Icon icon={RiMapPinLine} />
            <Chip.Label>Prague</Chip.Label>
          </Chip.Action>
        </Chip>
        {cities.includes('Warsaw') && (
          <Chip>
            <Chip.Label>Warsaw</Chip.Label>
            <Chip.IconButton aria-label="Remove Warsaw" onClick={() => removeCity('Warsaw')} />
          </Chip>
        )}
        {cities.includes('Berlin') && (
          <Chip variant="secondary" style="border">
            <Chip.Action onClick={() => setSelectedCity('Berlin')}>
              <Chip.Icon icon={RiMapPinLine} />
              <Chip.Label>Berlin</Chip.Label>
            </Chip.Action>
            <Chip.IconButton aria-label="Remove Berlin" onClick={() => removeCity('Berlin')} />
          </Chip>
        )}
      </div>
      <p role="status">{selectedCity ? `Applied city: ${selectedCity}` : 'No city applied'}</p>
      <Button
        ref={resetRef}
        preset="ghost"
        variant="secondary"
        size="xs"
        onClick={() => {
          setCities(['Warsaw', 'Berlin']);
          setSelectedCity(null);
        }}
      >
        Reset examples
      </Button>
    </div>
  );
}

States

The consumer owns selection: this example toggles a filter through Action's onClick and exposes its state with aria-pressed. disabled on Chip disables both buttons and skips them in the tab order; use it while an option is temporarily unavailable.

tsx
import { Chip } from '@/components/ui/wideset/chip/Chip';
import { useState } from 'react';

export default function ChipStates() {
  const [remoteOnly, setRemoteOnly] = useState(false);

  return (
    <div className="gap-ws-12 flex flex-wrap items-center">
      <Chip style={remoteOnly ? 'filled' : 'border'}>
        <Chip.Action aria-pressed={remoteOnly} onClick={() => setRemoteOnly((on) => !on)}>
          <Chip.Label>Remote only</Chip.Label>
        </Chip.Action>
      </Chip>
      <Chip disabled>
        <Chip.Action>
          <Chip.Label>Unavailable filter</Chip.Label>
        </Chip.Action>
        <Chip.IconButton aria-label="Remove unavailable filter" />
      </Chip>
    </div>
  );
}

API reference

Chip

NameDescriptionDefault
defaultMotion

Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`.

boolean
true
disabled

Disables both the main action and the removal button.

boolean
false
size
'sm''md''lg'
'md'
style
'border''filled'
'filled'
variant
'primary''secondary'
'primary'
Every other prop of <div> is passed through to it. See MDN: <div>.

Chip.Action

NameDescriptionDefault
disabled

Disables only this action. A disabled Chip always disables it too.

boolean
—
onClick

Main action supplied by the consumer; Chip does not automatically toggle or select.

MouseEventHandler<HTMLButtonElement>
—
type

Native button type; defaults to `button`, so activation does not submit a form.

'button''submit''reset'
'button'
Every other prop of <button> is passed through to it. See MDN: <button>.

Chip.IconButton

NameDescriptionDefault
aria-label

Defines a string value that labels the current element. Accessible action name. Provide this or `aria-labelledby`. Accessible action name including the value, such as `Remove Warsaw`. Use this or aria-labelledby.

string
—
aria-labelledby

Identifies the element (or elements) that labels the current element. ID of the element naming the action. Provide this or `aria-label`. ID of the element that names this button. Use instead of aria-label when appropriate.

string
—
className

Additional CSS classes merged with the icon button root.

string
—
disabled

Disables the icon button visually and functionally. Disables only this button. A disabled Chip always disables it too.

boolean
—
icon

Decorative icon; defaults to the close icon.

RemixiconComponentType
—
iconClassName

Additional CSS classes merged with the rendered icon.

string
—
onClick

Called when the user activates the icon button. Consumer-owned action, normally removing the item from application state. Chip does not hide itself.

MouseEventHandler<HTMLButtonElement>
—
type

Native button type used for form behavior. Native button type; defaults to `button`.

'button''submit''reset'
—

Chip.Icon

NameDescriptionDefault
icon*

Icon component rendered inside the chip and styled from the current chip context.

RemixiconComponentType
—
children—

Chip.Label

No props of its ownIt takes its content as children.
Every other prop of <span> is passed through to it. See MDN: <span>.

Accessibility

  • The root is passive. Chip.Action and Chip.IconButton are separate native buttons, each activated with Enter or Space and reached independently with Tab.
  • For a toggling filter, set aria-pressed on Chip.Action to the on/off state.
  • Leading icons are decorative. The removal button needs an accessible name that says so: aria-label="Remove Warsaw".
  • disabled on Chip disables both buttons through their native attributes. Each button can also be disabled independently.
  • After removing a chip, the consumer should move keyboard focus to a suitable remaining control, such as the next removal button or a reset control. Removing a focused item otherwise loses focus.
PartRendersDescription
Chip<div>A passive visual container for a label, optional main action, and optional removal button. Supply handlers on Action and IconButton; selection and removal are owned by the consumer.
Chip.Action<button>The optional native main button. Place the leading Icon and Label inside it.
Chip.IconButton—An independent native icon button, normally used for removal. Place it after Action or Label as a sibling. It inherits appearance, motion, and disabled state from Chip. Requires an accessible name through aria-label or aria-labelledby.
Chip.Icon—A decorative leading icon. Place it before Label, inside Action when one is present.
Chip.Label<span>The chip's text label, inside an action or directly inside a passive chip.
tsx
import { Chip } from '@/components/ui/wideset/chip/Chip';

<Chip>
  <Chip.Action>
    <Chip.Label>Remote only</Chip.Label>
  </Chip.Action>
  <Chip.IconButton aria-label="Remove Remote only filter" />
</Chip>

Appearance

Variant
Size
Style

Content

Main action
Leading icon
Removal button

State

Disabled