Angle Slider

A component for selecting a value within a circular range.

Loading...

Anatomy

Wind direction45°rootlabelthumbcontrolvalue text
<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.

AttributeDefaultType
aria-label
string

The accessible label for the slider thumb.

aria-labelledby
string

The id of the element that labels the slider thumb.

asChild
boolean

Use 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.
defaultValue0
number

The initial value of the slider. Use when you don't need to control the value of the slider.

disabled
boolean

Whether the slider is disabled.

id
string

The unique identifier of the machine.

ids
ElementIds

The ids of the elements in the machine. Useful for composition.

invalid
boolean

Whether the slider is invalid.

name
string

The name of the slider. Useful for form submission.

onValueChange
(details: ValueChangeDetails) => void

The callback function for when the value changes.

onValueChangeEnd
(details: ValueChangeDetails) => void

The callback function for when the value changes ends.

readOnly
boolean

Whether 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.

step1
number

The step value for the slider.

value
number

The value of the slider.

AttributeDescription
[data-angle-slider-root]<uid>
[data-disabled]Present when disabled
[data-invalid]Present when invalid
[data-readonly]Present when read-only
CSS VariableDescription
--valueThe current value
--angleThe angle in degrees

Control

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use 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.

AttributeDescription
[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.

AttributeDefaultType
asChild
boolean

Use 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.

AttributeDefaultType
asChild
boolean

Use 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.

AttributeDescription
[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.

AttributeDefaultType
asChild
boolean

Use 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.

AttributeDefaultType
value
number

The value of the marker

asChild
boolean

Use 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.

AttributeDescription
[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 VariableDescription
--marker-valueThe logical marker value (e.g. 0, 45, 90)
--marker-display-valueThe rotation angle for display (mirrored in RTL)

RootProvider

Defines the <div> element.

AttributeDefaultType
value
UseAngleSliderReturn

asChild
boolean

Use 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.

AttributeDefaultType
asChild
boolean

Use 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.

AttributeDescription
[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.

AttributeDefaultType
asChild
boolean

Use 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

PropertyType
value
number

The current value of the angle slider

valueAsDegree
string

The current value as a degree string

setValue
(value: number) => void

Sets the value of the angle slider

dragging
boolean

Whether the slider is being dragged.

getRootState
() => RootState

Returns the state of the angle slider

getMarkerState
(props: MarkerProps) => MarkerState

Returns the state of a specific marker