Skip to content

shadcn.io is not affiliated with official shadcn/ui

Shadcn Angle Slider for React Radix UI

A control for selecting an angle in a circular range.

Framework
UI library

Radix UI does not include this primitive, so this page uses the Ark UI component. The visuals match the Ark UI version.

0deg

Installation

bunx --bun shadcn@latest add https://kit.dev/r/radix/angle-slider.json

Anatomy

AngleSlider
├── AngleSliderLabel
├── AngleSliderThumb
├── AngleSliderValueText
├── AngleSliderControl
├── AngleSliderTrack
└── AngleSliderMarker
    └── AngleSliderMarkerGroup

Usage

import {
  AngleSlider,
  AngleSliderControl,
  AngleSliderHiddenInput,
  AngleSliderLabel,
  AngleSliderMarker,
  AngleSliderMarkerGroup,
  AngleSliderThumb,
  AngleSliderValueText,
} from "@/components/ui/angle-slider";
const MARKERS = [0, 45, 90, 135, 180, 225, 270, 315];

const Example = () => (
  <AngleSlider>
    <AngleSliderLabel>Rotation</AngleSliderLabel>
    <AngleSliderControl>
      <AngleSliderMarkerGroup>
        {MARKERS.map((value) => (
          <AngleSliderMarker key={value} value={value} />
        ))}
      </AngleSliderMarkerGroup>
      <AngleSliderThumb />
    </AngleSliderControl>
    <AngleSliderValueText />
    <AngleSliderHiddenInput />
  </AngleSlider>
);

Accessibility

KeyDescription
ArrowLeft
Decrease the value.
ArrowUp
Decrease the value.
ArrowRight
Increase the value.
ArrowDown
Increase the value.
Home
Go to the start.
End
Go to the end.

Demos

Context

Controlled

Disabled

Root Provider

Step

API Reference

AngleSlider

div

PropType
AttributeType
CSS variableType
--anglestring
--valuestring

AngleSliderLabel

label

PropType
AttributeType

AngleSliderThumb

div

PropType
AttributeType
CSS variableType
--sizestring
--thumb-widthstring

AngleSliderValueText

div

PropType
AttributeType

AngleSliderControl

div

PropType
AttributeType
CSS variableType
--sizestring
--track-widthstring

AngleSliderMarkerGroup

div

PropType
AttributeType

AngleSliderMarker

div

PropType
AttributeType
CSS variableType
--marker-display-valuestring
--marker-valuestring

AngleSliderHiddenInput

input

PropType
AttributeType

AngleSliderRootProvider

div

PropType
valueUseAngleSliderReturn
AttributeType
CSS variableType
--anglestring
--valuestring

useAngleSlider

PropType

AngleSliderContext

PropType