Skip to content
NewYour data: charts, lists and meters that take your records
<hf-chips>Custom elementInputsForm control

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.

View as Markdown
<hf-chips>

Your data

Pass your chips and counts as options (Label:count). Without it the chips show demo languages with invented counts. See Your data.

Playground

Change a prop and the component updates. Props marked live animate to the new value; the others rebuild the element.

Loading <hf-chips>
Props
optionslive
valuelive
labellive
nameremounts
disabledremounts
<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-chips
First 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}.json

Or skip the setup and install by URL:

npx shadcn@latest add https://elements.lumesec.ai/r/hf-chips.json

Usage

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:9

Comma-separated chips as Label:count, split at the last colon. The count is optional and shown after the label. Observed: a change rebuilds the chips and keeps the selected labels.

valueReact propvalueTypestringDefaultTypeScript,Rust

Comma-separated labels of the selected chips, matched exactly. Observed: a change updates the selection and becomes the selection a form reset restores. Reflects the current selection.

labelReact proplabelTypestringDefaultLanguages

Heading text; also labels the chip group. Observed.

nameReact propnameTypestring

Form field name used when the element is inside a form.

disabledReact propdisabledTypebooleanDefaultfalse

Presence attribute. Disables every chip and Clear; a disabled ancestor <fieldset> does the same. A disabled element is not submitted.

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 | null

The owning form, from ElementInternals.

name (read-only)Typestring | null

The name attribute. There is no setter; set the attribute instead.

Accessibility

  • Each chip is a native <button> with aria-pressed reflecting its state, inside a role="group" container labelled by the heading.
  • The Clear button shows the selected count and is disabled when nothing is selected; when it had focus, focus then moves to the first chip.
  • The fill and check are drawn on an aria-hidden canvas.
  • 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. Form reset restores the selection from the value set by markup or code; a disabled element is not submitted.
  • 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 value through the attribute or the property does not fire change. A chip toggled from the keyboard floods from its centre.
  • Omitting value selects TypeScript and Rust; value="" starts with nothing selected.
  • Chips wrap to the host's width.

Was this page helpful?