Components
Angle slider

Angle Slider

A component for selecting a value within a circular range.

45°

Examples

Basic

Here's a basic example of the Angle Slider component.

import { AngleSlider } from '@ark-ui/react/angle-slider'

export const Basic = () => {
  return (
    <AngleSlider.Root>
      <AngleSlider.Label>Wind direction</AngleSlider.Label>
      <AngleSlider.Control>
        <AngleSlider.Thumb />
        <AngleSlider.MarkerGroup>
          {[0, 45, 90, 135, 180, 225, 270, 315].map((value, i) => (
            <AngleSlider.Marker key={i} value={value} />
          ))}
        </AngleSlider.MarkerGroup>
      </AngleSlider.Control>
      <AngleSlider.ValueText />
      <AngleSlider.HiddenInput />
    </AngleSlider.Root>
  )
}

Controlled

Use the value and onValueChange props to control the value of the Angle Slider.

import { AngleSlider } from '@ark-ui/react/angle-slider'
import { useState } from 'react'

export const Controlled = () => {
  const [angle, setAngle] = useState(180)

  return (
    <AngleSlider.Root value={angle} onValueChange={({ value }) => setAngle(value)}>
      <AngleSlider.Label>Temperature</AngleSlider.Label>
      <AngleSlider.Control>
        <AngleSlider.Thumb />
        <AngleSlider.MarkerGroup>
          {[0, 45, 90, 135, 180, 225, 270, 315].map((value, i) => (
            <AngleSlider.Marker key={i} value={value} />
          ))}
        </AngleSlider.MarkerGroup>
      </AngleSlider.Control>
      <AngleSlider.ValueText>{angle} ºC </AngleSlider.ValueText>
      <AngleSlider.HiddenInput />
    </AngleSlider.Root>
  )
}

Steps

Use the step prop to set the discrete steps of the Angle Slider.

import { AngleSlider } from '@ark-ui/react/angle-slider'

export const Step = () => {
  return (
    <AngleSlider.Root step={15}>
      <AngleSlider.Label>Wind direction (15 step)</AngleSlider.Label>
      <AngleSlider.Control>
        <AngleSlider.Thumb />
        <AngleSlider.MarkerGroup>
          {[0, 45, 90, 135, 180, 225, 270, 315].map((value, i) => (
            <AngleSlider.Marker key={i} value={value} />
          ))}
        </AngleSlider.MarkerGroup>
      </AngleSlider.Control>
      <AngleSlider.ValueText />
      <AngleSlider.HiddenInput />
    </AngleSlider.Root>
  )
}

API Reference

Root

PropDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

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
Partial<{ root: string; thumb: string; hiddenInput: string; control: string; valueText: string }>

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.

step1
number

The step value for the slider.

value
number

The value of the slider.

Data AttributeValue
[data-scope]angle-slider
[data-part]root
[data-disabled]Present when disabled
[data-invalid]Present when invalid
[data-readonly]Present when read-only

Control

PropDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.
Data AttributeValue
[data-scope]angle-slider
[data-part]control
[data-disabled]Present when disabled
[data-invalid]Present when invalid
[data-readonly]Present when read-only

HiddenInput

PropDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.

Label

PropDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.
Data AttributeValue
[data-scope]angle-slider
[data-part]label
[data-disabled]Present when disabled
[data-invalid]Present when invalid
[data-readonly]Present when read-only

MarkerGroup

PropDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.

Marker

PropDefaultType
value
number

The value of the marker

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.
Data AttributeValue
[data-scope]angle-slider
[data-part]marker
[data-value]The value of the item
[data-state]
[data-disabled]Present when disabled

RootProvider

PropDefaultType
value
UseAngleSliderReturn

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.

Thumb

PropDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.
Data AttributeValue
[data-scope]angle-slider
[data-part]thumb
[data-disabled]Present when disabled
[data-invalid]Present when invalid
[data-readonly]Present when read-only

ValueText

PropDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior.

For more details, read our Composition guide.