šŸ“ Sign Up | šŸ” Log In

← Root | ↑ Up

ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā” │ šŸ“„ shadcn/directory/diceui/angle-slider │ ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

╔══════════════════════════════════════════════════════════════════════════════════════════════╗
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘

Angle Slider

A circular slider component for selecting angles with precise control and customizable appearance.

Dice UI

Installation

CLI

npx shadcn@latest add @diceui/angle-slider

Manual

Copy and paste the component source code into your project.

Usage

import {
  AngleSlider,
  AngleSliderRange,
  AngleSliderThumb,
  AngleSliderTrack,
  AngleSliderValue,
} from "@/components/ui/angle-slider";

<AngleSlider>
  <AngleSliderTrack>
    <AngleSliderRange />
  </AngleSliderTrack>
  <AngleSliderThumb />
  <AngleSliderValue />
</AngleSlider>

Layout

Import the parts and compose them together:

import {
  AngleSlider,
  AngleSliderRange,
  AngleSliderThumb,
  AngleSliderTrack,
  AngleSliderValue,
} from "@/components/ui/angle-slider";

<AngleSlider>
  <AngleSliderTrack>
    <AngleSliderRange />
  </AngleSliderTrack>
  <AngleSliderThumb />
  <AngleSliderValue />
</AngleSlider>

Examples

Controlled State

A slider with controlled state management and custom actions:

const [angle, setAngle] = React.useState([45]);

<AngleSlider value={angle} onValueChange={setAngle}>
  <AngleSliderTrack>
    <AngleSliderRange />
  </AngleSliderTrack>
  <AngleSliderThumb />
  <AngleSliderValue />
</AngleSlider>

Range Selection

Use multiple thumbs to create angle ranges with minimum step constraints:

<AngleSlider 
  defaultValue={[0, 180]} 
  minStepsBetweenThumbs={10}
>
  <AngleSliderTrack>
    <AngleSliderRange />
  </AngleSliderTrack>
  <AngleSliderThumb index={0} />
  <AngleSliderThumb index={1} />
  <AngleSliderValue />
</AngleSlider>

With Form

Integrate the angle slider with form validation and submission:

<form onSubmit={handleSubmit}>
  <AngleSlider name="rotation" defaultValue={[0]}>
    <AngleSliderTrack>
      <AngleSliderRange />
    </AngleSliderTrack>
    <AngleSliderThumb />
    <AngleSliderValue />
  </AngleSlider>
  <button type="submit">Submit</button>
</form>

Theming

You can customize the appearance by targeting specific components:

Track Theming

Use [&>[data-slot='angle-slider-track-rail']] to style the background track:

<AngleSliderTrack className="[&>[data-slot='angle-slider-track-rail']]:stroke-green-100" />

Range Theming

<AngleSliderRange className="stroke-green-500" />

Thumb Theming

<AngleSliderThumb className="border-green-500 bg-green-50 ring-green-500/50" />

Value Theming

<AngleSliderValue className="text-green-600 dark:text-green-400" />

API Reference

Root

The main container component for the angle slider.

| Prop | Type | Description | Default | | :--- | :--- | :--- | :--- | | value | number[] | Controlled value of the slider | - | | defaultValue | number[] | Default value when uncontrolled | [0] | | onValueChange | (value: number[]) => void | Callback fired when value changes | - | | onValueCommit | (value: number[]) => void | Callback fired when interaction ends | - | | min | number | Minimum value | 0 | | max | number | Maximum value | 100 | | step | number | Step increment | 1 | | minStepsBetweenThumbs | number | Minimum steps between thumbs | 0 | | size | number | Radius of the circular track | 60 | | thickness | number | Thickness of the track | 8 | | startAngle | number | Starting angle in degrees | -90 | | endAngle | number | Ending angle in degrees | 270 | | disabled | boolean | Whether the slider is disabled | false | | inverted | boolean | Inverts the slider direction | false | | dir | "ltr" \| "rtl" | Text direction | "ltr" | | name | string | Name for form submission | - | | form | string | Associated form id | - |

Data Attributes:

| Data Attribute | Value | | :--- | :--- | | [data-disabled] | Present when the angle slider is disabled. |

Track

The circular track that represents the full range of possible values.

Data Attributes:

| Data Attribute | Value | | :--- | :--- | | [data-disabled] | Present when the angle slider is disabled. | | [data-slot='angle-slider-track-rail'] | Present on the rail of the track. |

Range

The portion of the track that represents the selected range.

Data Attributes:

| Data Attribute | Value | | :--- | :--- | | [data-disabled] | Present when the angle slider is disabled. |

Thumb

The draggable handle for selecting values.

| Prop | Type | Description | Default | | :--- | :--- | :--- | :--- | | index | number | Index of the thumb in multi-thumb scenarios | 0 |

Data Attributes:

| Data Attribute | Value | | :--- | :--- | | [data-disabled] | Present when the angle slider is disabled. |

Value

Displays the current value(s) with customizable formatting.

| Prop | Type | Description | Default | | :--- | :--- | :--- | :--- | | unit | string | Unit to display after the value | "°" | | formatValue | (value: number \| number[]) => string | Custom formatter function | - |

Data Attributes:

| Data Attribute | Value | | :--- | :--- | | [data-disabled] | Present when the angle slider is disabled. |

Accessibility

The angle slider component includes comprehensive accessibility features:

Keyboard Interactions

| Key | Action | | :--- | :--- | | ArrowUp / ArrowRight | Increase the value by one step. | | ArrowDown / ArrowLeft | Decrease the value by one step. | | PageUp | Increase the value by ten steps. | | PageDown | Decrease the value by ten steps. | | Shift + Arrow Keys | Increase/decrease the value by ten steps. | | Home | Set the value to the minimum. | | End | Set the value to the maximum. |

ARIA Features

  • Proper role="slider" semantics
  • aria-valuemin, aria-valuenow, aria-valuemax attributes
  • Keyboard navigation support
  • Focus management for multiple thumbs
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•‘
ā•šā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•ā•

← Root | ↑ Up