Skip to content
Stylhero 0.8.0
Components

Core

Layout and type

Inputs

Overlays

Navigation

Data display

Charts

Transitions and utilities

Page pieces (landing pages, portfolios, docs)

Icons

Components / Inputs

Chip

Compact pill for filters, tags and selected values.

import { Chip } from "@stylhero/ui";

Example

Code
import { useState } from "react";
import { Chip, Stack } from "@stylhero/ui";

function ChipExample() {
  const [tags, setTags] = useState(["AMD", "Quiet", "Small"]);
  const [picked, setPicked] = useState(false);
  return (
    <Stack direction="row" gap={2} wrap>
      <Chip selected={picked} onClick={() => setPicked(!picked)}>Under $1,000</Chip>
      {tags.map((t) => <Chip key={t} onRemove={() => setTags(tags.filter((x) => x !== t))}>{t}</Chip>)}
    </Stack>
  );
}

Props

PropTypeDefaultDescription
children required ReactNode -
icon ReactNode -
onClick () => void -
onRemove () => void - Shows a remove (x) button.
selected boolean - With onClick: a filter chip that shows a check when selected.

Also takes every <span> attribute (id, style, data-*, aria-*, event handlers…), passed to that element.

Keyboard

KeyDoes
Enter / SpaceActivates a clickable chip, or its remove button

Accessibility

  • A clickable chip is a button with aria-pressed for selected; the remove button is labelled "Remove …".

Generated from src/components/Chip.tsx. Something wrong or missing? Open an issue.