Filter chips
Multi-select filter chips: selecting floods a chip with dots from the click point and draws a check. Submits one value per chip.
Playground
Change a prop and the component updates. Props marked live animate to the new value; the others rebuild the element.
<HfChips options="TypeScript:128,Python:96,Rust:41,Go:37,SQL:22,Shell:18,Swift:9" value="TypeScript,Rust" label="Languages" name="lang" />
Installation
pnpm dlx shadcn@latest add @lumesec/hf-chipsFirst timeRegister the @lumesec registry once, or install by URL+
Adds @lumesec to your components.json:
pnpm dlx shadcn@latest registry add @lumesec=https://elements.lumesec.ai/r/{name}.jsonOr skip the setup and install by URL:
npx shadcn@latest add https://elements.lumesec.ai/r/hf-chips.jsonUsage
import { HfChips } from "@/components/lumesec/hf-chips";
export function Example() {
return (
<HfChips name="lang" label="Languages" value="TypeScript,Rust" />
);
}Behaviour
Selecting a chip floods it with dots from where you clicked and draws a pixel check; Clear empties them all. Submits one form value per selected chip.
API reference
Attributes
optionsReact propoptionsTypestringDefaultTypeScript:128,Python:96,Rust:41,Go:37,SQL:22,Shell:18,Swift:9Comma-separated chips as Label:count. The count is optional and shown after the label. Read once on connect.
valueReact propvalueTypestringDefaultTypeScript,RustComma-separated labels of the selected chips, matched exactly. Observed: a change updates the selection. Reflects the current selection.
labelReact proplabelTypestringDefaultLanguagesHeading text. Read once on connect.
nameReact propnameTypestringForm field name used when the element is inside a form.
Events
Events bubble and cross the shadow boundary unless the description says otherwise.
changeReact proponChangeDetail{ value: string[] }Fires when the user toggles a chip or presses Clear. value lists the selected labels in option order.
Properties
valueTypestring[]Selected labels. Setting accepts an array or a comma-separated string and writes the value attribute.
options (read-only)Type{ label: string; count?: string }[]The parsed options.
form (read-only)TypeHTMLFormElement | nullThe owning form, from ElementInternals.
name (read-only)Typestring | nullThe name attribute. There is no setter; set the attribute instead.
Accessibility
- Each chip is a native
<button>witharia-pressedreflecting its state, inside arole="group"container that has no label. - The Clear button shows the selected count and is disabled when nothing is selected.
- The fill and check are drawn on an
aria-hiddencanvas. - Form-associated through
ElementInternals. - With
name, submits one entry per selected chip under that name; without a name the internal value is the comma-joined labels. There is no validation, and form reset anddisabledare not handled. - Reduced motion: a chip fills and draws its check at once instead of flooding from the click point; the hover tint still eases.
Theming
The element reads your shadcn theme tokens through its shadow root, so light and dark follow your theme. The accent comes from --lumesec. See Theming.
This component reads --foreground, --lumesec and --muted-foreground.
To restyle only LumeSec elements, set the matching --ui-* overrides: --ui-accent, --ui-fg and --ui-muted.
Notes
- Setting
valuethrough the attribute or the property does not firechange. - Omitting
valueselects TypeScript and Rust;value=""starts with nothing selected. - Chips wrap to the host's width.
Related
Was this page helpful?