Range filter
Dual-thumb range filter over a dithered histogram; bars inside the range light up and a result count follows as you drag or type.
Playground
Change a prop and the component updates. Props marked live animate to the new value; the others rebuild the element.
<HfRange
min={0}
max={500}
step={5}
low={100}
high={350}
prefix="€"
scale={3}
label="Price per month"
unitLabel="results"
name="price"
/>Installation
pnpm dlx shadcn@latest add @lumesec/hf-rangeFirst 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-range.jsonUsage
import { HfRange } from "@/components/lumesec/hf-range";
export function Example() {
return (
<HfRange name="price" label="Price per month" min={0} max={500} step={5} low={100} high={350} />
);
}Behaviour
Two thumbs over a dithered histogram. Bars inside the range light up, the result count rolls, and the min and max fields stay in sync both ways.
API reference
Attributes
minReact propminTypenumberDefault0Lower bound of the scale.
maxReact propmaxTypenumberDefault500Upper bound of the scale.
stepReact propstepTypenumberDefault5Snap increment. Also the arrow-key step and the minimum gap between the two thumbs.
lowReact proplowTypenumberInitial lower value. Defaults to min plus 20% of the range, rounded to step.
highReact prophighTypenumberInitial upper value. Defaults to min plus 70% of the range, rounded to step.
prefixReact propprefixTypestringDefault€Text before values in the Min and Max fields and in aria-valuetext. An empty attribute removes it.
dataReact propdataTypestringComma-separated bar heights for the histogram, spread evenly from min to max. Needs at least four numbers; otherwise a built-in demo distribution of 44 bars is used.
scaleReact propscaleTypenumberDefault3Multiplier from the summed heights of the bars in range to the result count in the header.
labelReact proplabelTypestringDefaultPriceHeading text.
unit-labelReact propunitLabelTypestringDefaultresultsWord after the result count.
nameReact propnameTypestringForm field name. With a name, the form receives <name>-min and <name>-max.
Events
Events bubble and cross the shadow boundary unless the description says otherwise.
inputReact proponInputDetail{ min: number, max: number }Fires on every value change: while dragging, on key presses and when a Min or Max field is committed.
changeReact proponChangeDetail{ min: number, max: number }Fires when a drag ends, after each arrow, Page, Home or End key press, and when a Min or Max field is committed.
Properties
min (read-only)TypenumberThe min attribute, or 0.
max (read-only)TypenumberThe max attribute, or 500.
step (read-only)TypenumberThe step attribute, or 5.
bins (read-only)Typenumber[]The histogram bar heights in use, from data or the demo distribution.
form (read-only)TypeHTMLFormElement | nullThe owning form, from ElementInternals.
name (read-only)Typestring | nullThe name attribute. There is no setter; set the attribute instead.
Keyboard
| Keys | Action |
|---|---|
| ArrowRight / ArrowUp | Raise the focused thumb by step. |
| ArrowLeft / ArrowDown | Lower the focused thumb by step. |
| PageUp / PageDown | Move the focused thumb by a tenth of the range. |
| Home / End | Move the focused thumb to min or max, stopping one step from the other thumb. |
Accessibility
- Both thumbs are focusable with
role="slider",aria-labelMinimumorMaximum,aria-valuemin,aria-valuemax,aria-valuenowand anaria-valuetextthat includes the prefix. - The Min and Max text fields carry matching
aria-labels andinputmode="numeric". - The result count is an
aria-live="polite"region. - Pressing on the track moves and focuses the nearest thumb. The histogram canvas is
aria-hidden. - Form-associated through
ElementInternals. - With
name, submits two entries,<name>-minand<name>-max; without a name the internal value islow-high. There is no validation, and form reset anddisabledare not handled. - Reduced motion: histogram bars switch between lit and unlit at once and the result count changes without the roll; the thumb glow 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 --border, --card, --foreground, --lumesec and --muted-foreground.
To restyle only LumeSec elements, set the matching --ui-* overrides: --ui-accent, --ui-border, --ui-fg, --ui-muted and --ui-surface.
Notes
- The host is
display: block; the plot is 118px tall and fills the host's width. - Attributes are read when the element connects and are not observed. The thumbs always stay at least one
stepapart. - There is no
valueproperty; read the range from theinputandchangedetails or from the form data. - The Min and Max fields' native
inputevents stay inside the shadow root; only the element's owninputandchangeevents, withminandmaxindetail, reach the host.
Related
Was this page helpful?