shadcn.io is an independent project built on shadcn/ui
On this page9 sections
A circular slider is a knob: a ring that fills clockwise from the top as its thumb turns, with room in the middle for the value, a unit or an icon. It returns an angle from 0 to 359 degrees, which you map to your own scale, such as a percentage for a volume knob.
For a bare dial with a needle and tick marks, use the Angle Slider. A value people compare against a straight scale reads better on a Slider.
Installation
Anatomy

Usage
<script setup lang="ts">
import {
CircularSlider, CircularSliderValue,
} from "@/components/ui/circular-slider";
</script>
CircularSlider draws the ring, the thumb and any ticks itself. What you put inside it, here the value with a degree sign, sits in the center.
<template>
<CircularSlider aria-label="Angle" :defaultValue=45>
<CircularSliderValue suffix="°" />
</CircularSlider>
</template>
Accessibility
The thumb has the slider role, takes focus with Tab and reports the angle as its value, and invalid as aria-invalid. Name it with a CircularSliderLabel inside the knob, or with aria-label on CircularSlider when no label shows: without either, a screen reader announces a nameless slider. The value is read as an angle with a degree sign, such as 45°, whatever scale you map it to, so when the angle stands for something else, say what in the name. The ring is drawn for sight only and is hidden from assistive technology.
- Arrow Right
- Increases the angle by one step, going round from the last step to 0. Right to left, it decreases it.
- Arrow Left
- Decreases the angle by one step, going round from 0 to the last step. Right to left, it increases it.
- Arrow Up
- Increases the angle by one step, going round from the last step to 0.
- Arrow Down
- Decreases the angle by one step, going round from 0 to the last step.
- Shift+Arrow Up
- Increases the angle by ten steps, at most a quarter turn.
- Shift+Arrow Down
- Decreases the angle by ten steps, at most a quarter turn.
- Shift+Arrow Right
- Increases the angle by ten steps, at most a quarter turn. Right to left, it decreases it.
- Shift+Arrow Left
- Decreases the angle by ten steps, at most a quarter turn. Right to left, it increases it.
- Page Up
- Increases the angle by ten steps, at most a quarter turn.
- Page Down
- Decreases the angle by ten steps, at most a quarter turn.
- Home
- Sets the angle to 0 degrees.
- End
- Sets the angle to the last step before the top: 359 degrees at the default step of 1.
Demos
Context
CircularSliderContext hands its child the slider's state, and this heading knob turns slider.value into a compass point, so the center reads NE 45° and changes as the thumb turns. Reach for the context when the center shows something calculated from the angle, such as a direction, a percentage or a time of day, and keep prefix and suffix for a plain unit.
Controlled
The angle starts at 45 in state, goes in as value and comes back through @value-change, and a line under the ring prints it with a degree sign. Hold the angle yourself when a caption, a reset button or a save handler reads it. When nothing reads it until the form is sent, defaultValue and a name are enough.
Custom markers
markers set to [0, 90, 180, 270] draws four ticks, at the top, right, bottom and left, and each takes the primary color once the ring reaches it. Use a list when only a few angles mean something, such as the points of a compass. The thumb still moves by step, one degree here, so it doesn't stop on the ticks.
Disabled
disabled fades the knob at 45 degrees, ignores the pointer and takes the thumb out of the tab order. Use it when a preset owns the value or the setting isn't available yet, and the angle is still worth showing. For a value that is wrong and must be fixed, keep the knob enabled and mark it invalid instead.
Invalid
invalid turns the filled arc and the thumb's outline to the destructive color and marks the thumb with aria-invalid, so a screen reader says the value is invalid. Use it when the angle fails a rule the form checks, and keep a text message beside the knob, since a color alone doesn't say what is wrong.
Read only
readOnly keeps the knob at 90 degrees and refuses drags and keys, while the thumb stays in the tab order so people can still focus it and hear the value. Use it for a confirmed setting people should be able to inspect. It looks like an editable knob, so say nearby that it can't be changed, or use disabled when it should fade.
Root provider
useCircularSlider creates the state outside the knob, starting at 45 and named Angle through its aria-label option, and CircularSliderRootProvider hands it to the knob. The line above prints slider.value, and the Set to 90 button calls setValue. Use it when a preset or a neighbouring control must move the knob or read its value.
Size
size is the diameter in pixels, 180 here against the default of 100. The ring grows with it while the thumb keeps its size, which follows thickness. Use a large knob when it is the main control on the screen, such as a volume knob or a thermostat, rather than one field among many in a form.
Step
step is 60, so dragging and the arrow keys move in 60 degree jumps from a start of 120, and markers with markersAtSteps puts a tick on each stop from 0 to 300. A drag snaps to the nearest stop, and near the top that stop is 0, so the ring empties there rather than filling. Use the pair for a coarse choice, such as one of six presets.
Thickness
thickness is the ring's stroke in pixels, 14 here against the default of 6, and the thumb grows with it, as ticks would, while the diameter stays at size. Use a heavy ring when the knob is small and a thin track would vanish, or when the fill itself is what people watch.
With label
CircularSliderLabel puts Hue in the middle of the knob and names the thumb, so a screen reader says Hue and the angle. Use a visible label when nothing else on the screen says what the knob sets. When the word would crowd the center, pass aria-label to CircularSlider instead, as most demos here do.
With markers
markers set to true draws six ticks, one every 60 degrees from the top, with no list of angles to write, and the ticks the ring has reached take the primary color. Use them for a sense of position on a full turn, such as a heading or a timer. They don't make the thumb stop on them, since step decides that.
With value
CircularSliderValue fills the center with a thermometer icon from prefix, the angle and a degree sign from suffix, on a 120 pixel knob with a 10 pixel ring. The icon is hidden from screen readers, since the knob's aria-label already says Temperature. Use prefix and suffix for a plain unit, and the context for a calculated one.
FAQ
What value does a Circular Slider return?
An angle in whole degrees, from 0 at the top, clockwise to 359, moving by step, which is 1 by default. The ring fills in proportion to it. With a coarser step, a drag snaps to the nearest step, and the top always reads 0, so the value never reaches 360.
Map it to your own scale where you read it. For a volume knob from 0 to 100, divide by 3.6 and round, which reaches 100 at 359. For a scale that doesn't start at zero, add its minimum after scaling.
How do I control the Circular Slider value in Vue?
Hold the angle in a ref and bind it with v-model, which reads and writes the number of degrees. The Controlled demo passes value and listens to @value-change instead, which receives the new angle first and works the same way.
For a starting angle without state of your own, set defaultValue. To move the knob from a button elsewhere on the page, the Root provider demo's setValue is the other way in.
How do I run code only when the user releases the Circular Slider?
Listen to @value-change-end. It fires once when the pointer is released and once after each key press, while @value-change fires on every move of a drag.
That is the place to save the value or call an API, so a request doesn't go out for every degree the knob passes on its way round.
How do I add tick marks to a Circular Slider?
Set markers to true for six ticks, one every 60 degrees, or pass an array of angles for your own, as the With markers and Custom markers demos do. With markers set to true and markersAtSteps, a tick goes on every step instead.
Ticks show positions and never make the thumb stop on them. Set step to the gap between ticks when it should.
Can a Circular Slider be used with the keyboard?
Yes. The thumb takes focus with Tab, the arrow keys move it by step, Shift with an arrow or Page Up and Page Down by ten steps, and Home and End go to 0 and to the last step before the top, 359 by default. The keys go round the top rather than stopping there.
Give the knob a name with CircularSliderLabel or aria-label. A screen reader hears the value as an angle, such as 45°, so when it stands for something else, say what in the name. The Accessibility section lists every key.
Does the Circular Slider submit with a form?
Yes. The knob always renders a hidden input, so give CircularSlider a name, and the angle submits with the form as a number of degrees.
A knob with disabled disables that input too, so its angle stays out of the form data, as a native disabled field's would. One with readOnly still sends its value, which suits a confirmed setting the form has to carry.
How do I change the size of a Circular Slider?
Set size for the knob's diameter and thickness for its ring, both in pixels, 100 and 6 by default, as the Size and Thickness demos show. The thumb follows thickness, so a bigger knob with a thin ring keeps a small thumb.
size sets the knob's width and height directly, so a class can't make it fluid. For a knob that scales with its container, measure the container and pass the number.
How do I change the colors of a Circular Slider?
Edit components/ui/circular-slider, which is your code once installed. The ring is two circles in CircularSliderProgressRing, the track with stroke-muted and the fill with stroke-primary, and the thumb is a white dot with a ring-border outline in CircularSliderThumb.
With invalid, the fill and the thumb's outline switch to stroke-destructive and ring-destructive through in-data-invalid: classes on the same two parts, so change those classes for a different error color.
API Reference
CircularSlider
value?number
The angle. Pass it to control the slider. Two-way with v-model.
defaultValue?number
The angle at first, when uncontrolled. A form reset returns to it.
- Default
0
disabled?boolean
Whether it's disabled.
form?string
The id of a form to belong to, when it isn't inside that form.
ids?{ label?: string }
Ids for the parts. label names the thumb even when the label is an element of your own.
invalid?boolean
Whether it's invalid.
markers?boolean | number[]
Tick marks. true uses clock ticks (every 60°). A number array is custom angles.
- Type
boolean | number[]
markersAtSteps?boolean
When markers is true, place a tick at every step instead of clock ticks.
- Default
false
name?string
The name the angle submits under.
readOnly?boolean
Keeps it focusable and submitted, but drags and keys don't change it.
size?number
Diameter of the ring, in pixels.
- Default
100
step?number
How far a key or a drag moves, in degrees.
- Default
1
style?StyleValuethickness?number
Stroke width of the ring, in pixels.
- Default
6
#render?{ props, state, children }
A slot that renders your own element: bind its props with v-bind="props". It also gets the part's state, and children, its content.
class?string
Merged with the part's classes.
@value-change(details: AngleSliderValueChangeDetails) → void
Runs on every change, from a drag, a key or setValue.
- Type
(details: AngleSliderValueChangeDetails) → void- Parameters
details– { cancel: () → void; event?: Event; reason: AngleSliderValueChangeReason; source: ChangeSource; value: number; valueAsDegree: string }- Returns
void
@value-change-end(details: AngleSliderValueChangeEndDetails) → void
Runs once a drag or a key press that changed the angle ends.
- Type
(details: AngleSliderValueChangeEndDetails) → void- Parameters
details– AngleSliderValueChangeEndDetails- Returns
void
CircularSliderRootProvider
<svg>
valueobject
What useCircularSlider() returns: the state and API, made outside the component to control it.
- Type
{ dragging: boolean; setValue: (value: number) → void; value: number; valueAsDegree: string }
markers?boolean | number[]
Tick marks. true uses clock ticks (every 60°). A number array is custom angles.
- Type
boolean | number[]
markersAtSteps?boolean
When markers is true, place a tick at every step instead of clock ticks.
- Default
false
size?number
Diameter of the ring, in pixels.
- Default
100
step?number
Used with markersAtSteps to place ticks. Should match the hook's step. * * @default 1.
- Default
1
style?StyleValuethickness?number
Stroke width of the ring, in pixels.
- Default
6
#render?{ props, state, children }
A slot that renders your own element: bind its props with v-bind="props". It also gets the part's state, and children, its content.
class?string
Merged with the part's classes.
CircularSliderThumb
style?StyleValueclass?string
Merged with the part's classes.
--anglestring--sizestringCircularSliderLabel
style?StyleValueclass?string
Merged with the part's classes.
CircularSliderValue
prefix?VNode
Shown before the value, such as an icon.
style?StyleValuesuffix?VNode
Shown after the value, such as a unit (°).
class?string
Merged with the part's classes.
CircularSliderMarkerGroup
style?StyleValueclass?string
Merged with the part's classes.
CircularSliderMarker
style?StyleValueclass?string
Merged with the part's classes.
--marker-heightstring--marker-offsetstring--marker-valuestring--marker-widthstring











