UIComponentsReact
A dial for an angle, such as a direction or a rotation, dragged around the circle or set with the keys.
Built on the headless Angle Slider.See its API in Docs
Rendered by React 19.3.1
Installation
npx shadcn@4.23.0 add https://hamur.dev/r/react/angle-slider.jsonIt also adds utils. The app needs its setup first: Installation.
Usage
Give defaultValue (or value) in degrees, 0 at the top and clockwise; step and largeStep set the positions and the jump of Shift and Page Up/Down. AngleSlider renders only its children: an AngleSliderLabel names it, and an AngleSliderControl, the dial, holds an AngleSliderIndicator (the needle), one AngleSliderMarker per tick with its value, an AngleSliderValue in the middle and the AngleSliderThumb on the rim. The rim fills from 0 to the value, and the ticks up to it take data-filled. A press anywhere on the dial moves the thumb there, a drag crosses 0 freely, and the keys wrap past the last position. The slider, its keys, the value text and the form value come from the headless Angle Slider. For a number in a range, use the Slider.
import {
AngleSlider,
AngleSliderControl,
AngleSliderIndicator,
AngleSliderLabel,
AngleSliderMarker,
AngleSliderThumb,
AngleSliderValue,
} from '@/components/ui/angle-slider'Examples
Default
A dial at 120° with a tick every 30°, the needle and value.
The rim is the Slider's bg-muted track, filled in the primary colour through --angle-slider-angle, and the thumb is the Slider's; the ticks are turned by --angle-slider-marker-angle. The value is written as text in the middle and spelled with its unit for screen readers ("120 degrees"), so the angle is never shown by the fill alone (WCAG 1.4.1); under forced colours, where backgrounds are not drawn, the rim, ticks and needle are outlined. This item takes Base UI's component ID as its slug.
API reference
The styled parts pass every prop to the headless part they wrap and add classes. The props, data attributes and keyboard are on Angle Slider's API reference.