Rotary dial
Rotary dial that follows the pointer around a 270° arc, flashing a tick and rolling the value at each detent, then springs onto the step.
Playground
Change a prop and the component re-renders. Props marked remounts set an initial value, so the component starts over.
<UiDial
defaultValue={0.7}
min={0}
max={1}
step={0.1}
label="Temperature"
/>Installation
pnpm dlx shadcn@latest add @lumesec/ui-dialFirst 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/ui-dial.jsonUsage
import { UiDial } from "@/components/lumesec/ui-dial";
export function Example() {
return <UiDial defaultValue={0.7} min={0} max={1} step={0.1} label="Temperature" />;
}Behaviour
Drag around the knob and it follows your pointer, with a click at each detent: the tick flashes, the knob nudges and the value rolls. Let go and it springs onto the nearest step.
API reference
Props
Also accepts every prop of <div> (React.ComponentProps<"div">), spread onto the root element.
valueTypenumberControlled value, snapped to step and clamped to min and max. Use with onValueChange.
defaultValueTypenumberDefault0.7Initial value when uncontrolled.
minTypenumberDefault0Lowest value.
maxTypenumberDefault1Highest value.
stepTypenumberDefault0.1Detent size. Its decimal places set the display precision.
labelTypestringDefault"Temperature"Caption under the dial and the slider's aria-label.
onValueChangeType(value: number) => voidCalled on every detent change from drag, wheel or keys.
onValueCommitType(value: number) => voidCalled with each wheel or key step, and when a drag ends, even if the value did not change.
Ref
ref points at the root HTMLDivElement.
Keyboard
| Keys | Action |
|---|---|
| ArrowUp / ArrowRight | Increase by one step. |
| ArrowDown / ArrowLeft | Decrease by one step. |
| Home / End | Jump to min / max. |
Accessibility
- The dial has
role="slider",tabindex="0",aria-valuenow,aria-valuemin,aria-valuemaxand anaria-labelfromlabel. - Pressing on the dial moves focus to it.
- The tick marks are
aria-hidden, as are the min and max labels. - Reduced motion: the knob settles on the step angle without overshoot, ticks do not flash, the knob does not nudge and the value swaps without rolling.
Theming
Styled with Tailwind classes on your shadcn theme tokens, so light and dark follow your theme. The accent comes from --lumesec. See Theming.
This component reads --lumesec, --lumesec-glint, --foreground, --muted-foreground, --card, --muted and --border.
Notes
- Dragging into the 90° gap at the bottom of the arc sticks to the nearer end. The scroll wheel over the dial changes one step per tick and does not scroll the page; sideways scrolling is ignored.
- With 16 or fewer detents each step gets a major tick plus two minor ticks; with more, one tick per detent.
- Changing
valuefrom outside springs the knob to it and flashes its tick without calling either callback.
Related
Was this page helpful?