Angle Slider
A component for selecting a value within a circular range.
Anatomy
<AngleSlider.Root>
<AngleSlider.Label />
<AngleSlider.Control>
<AngleSlider.Thumb />
<AngleSlider.MarkerGroup>
<AngleSlider.Marker />
</AngleSlider.MarkerGroup>
</AngleSlider.Control>
<AngleSlider.ValueText />
<AngleSlider.HiddenInput />
</AngleSlider.Root>
Examples
Basic
Controlled
Use value and onValueChange to control the value.
Steps
Set step to snap the value to discrete increments.
API Reference
Props
Root
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
aria-label | stringThe accessible label for the slider thumb. | |
aria-labelledby | stringThe id of the element that labels the slider thumb. | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
defaultValue | 0 | numberThe initial value of the slider. Use when you don't need to control the value of the slider. |
disabled | booleanWhether the slider is disabled. | |
id | stringThe unique identifier of the machine. | |
ids | ElementIdsThe ids of the elements in the machine. Useful for composition. | |
invalid | booleanWhether the slider is invalid. | |
name | stringThe name of the slider. Useful for form submission. | |
onValueChange | (details: ValueChangeDetails) => voidThe callback function for when the value changes. | |
onValueChangeEnd | (details: ValueChangeDetails) => voidThe callback function for when the value changes ends. | |
readOnly | booleanWhether the slider is read-only. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<AngleSliderRootState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. | |
step | 1 | numberThe step value for the slider. |
value | numberThe value of the slider. |
| Attribute | Description |
|---|---|
[data-angle-slider-root] | <uid> |
[data-disabled] | Present when disabled |
[data-invalid] | Present when invalid |
[data-readonly] | Present when read-only |
| CSS Variable | Description |
|---|---|
--value | The current value |
--angle | The angle in degrees |
Control
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-angle-slider-control] | <uid> |
[data-disabled] | Present when disabled |
[data-invalid] | Present when invalid |
[data-readonly] | Present when read-only |
HiddenInput
Defines the <input> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
Label
Defines the <label> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-angle-slider-label] | <uid> |
[data-disabled] | Present when disabled |
[data-invalid] | Present when invalid |
[data-readonly] | Present when read-only |
MarkerGroup
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
Marker
Defines the <span> element.
| Attribute | Default | Type |
|---|---|---|
value | numberThe value of the marker | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<AngleSliderMarkerState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-angle-slider-marker] | <uid> |
[data-value] | The value of the item |
[data-state] | "under-value" | "over-value" | "at-value" |
[data-disabled] | Present when disabled |
| CSS Variable | Description |
|---|---|
--marker-value | The logical marker value (e.g. 0, 45, 90) |
--marker-display-value | The rotation angle for display (mirrored in RTL) |
RootProvider
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
value | UseAngleSliderReturn | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | type ONLY_FOR_FORMAT =
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<AngleSliderRootProviderState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
Thumb
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-angle-slider-thumb] | <uid> |
[data-disabled] | Present when disabled |
[data-invalid] | Present when invalid |
[data-readonly] | Present when read-only |
ValueText
Defines the <span> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
Context
API
| Property | Type |
|---|---|
value | numberThe current value of the angle slider |
valueAsDegree | stringThe current value as a degree string |
setValue | (value: number) => voidSets the value of the angle slider |
dragging | booleanWhether the slider is being dragged. |
getRootState | () => RootStateReturns the state of the angle slider |
getMarkerState | (props: MarkerProps) => MarkerStateReturns the state of a specific marker |