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
| Prop | Type | Default | Description |
|---|---|---|---|
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
| Key | Does |
|---|---|
| Enter / Space | Activates a clickable chip, or its remove button |
Accessibility
- A clickable chip is a button with
aria-pressedforselected; the remove button is labelled "Remove …".
Generated from src/components/Chip.tsx. Something wrong or missing? Open an issue.