---
title: "Angle Slider · Ark UI — StyleX Blocks"
description: "Circular dial for picking an angle, with a value arc, draggable thumb and optional markers."
url: "https://stylexblocks.com/components/ark-ui/angle-slider/"
agent:
  instructions: "Use this search API to find relevant components and blocks across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://stylexblocks.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Angle Slider

Circular dial for picking an angle, with a value arc, draggable thumb and optional markers.

- Behavior engine: Ark UI
- Also available for: [Base UI](https://stylexblocks.com/components/base-ui/angle-slider.md), [UI SDK](https://stylexblocks.com/components/ui-sdk/angle-slider.md)
- Category: Form
- Variants: outline, solid
- Sizes: sm, md, lg
- HTML page: https://stylexblocks.com/components/ark-ui/angle-slider/

## Install

Configure the project once (sets the behavior engine and import aliases):

```sh
npx stylexblocks init
```

Then add the item as source you own:

```sh
npx stylexblocks add angle-slider
```

Equivalent: `npx shadcn add @stylexblocks/angle-slider`. Registry item JSON: https://stylexblocks.com/r/ark-ui/angle-slider.json

## Usage

```tsx
import { AngleSlider } from "#components/ui/ark-ui/angle-slider.tsx";
import { indigoPalette } from "@stylexblocks/ui/themes/palettes.ts";

export function Example() {
  return (
    // variant/size resolve once on Root; Control renders Thumb + ValueText
    // by default — pass children to add markers
    <AngleSlider.Root defaultValue={45} variant="outline" size="md" palette={indigoPalette}>
      <AngleSlider.Label>Rotation</AngleSlider.Label>
      <AngleSlider.Control>
        <AngleSlider.MarkerGroup>
          {[0, 90, 180, 270].map((value) => (
            <AngleSlider.Marker key={value} value={value} />
          ))}
        </AngleSlider.MarkerGroup>
        <AngleSlider.Thumb />
        <AngleSlider.ValueText />
      </AngleSlider.Control>
      <AngleSlider.HiddenInput />
    </AngleSlider.Root>
  );
}

// controlled: <AngleSlider.Root value={angle} onValueChange={(d) => setAngle(d.value)}>
// step: <AngleSlider.Root step={15}>
```

## Source

`components/ui/ark-ui/angle-slider.tsx`

```tsx
import {
  AngleSlider as ArkAngleSlider,
  useAngleSliderContext,
} from "@ark-ui/react/angle-slider";
import { createSlotRecipeContext } from "#lib/ark-ui/create-slot-recipe-context.tsx";
import { defineSlotRecipe } from "#lib/recipe-props.ts";
import * as stylex from "@stylexjs/stylex";
import { colorPalette } from '@stylexblocks/ui/color-palette.stylex.ts'
import { fontSizes } from '@stylexblocks/ui/tokens/font-sizes.stylex.ts'
import { fontWeights } from '@stylexblocks/ui/tokens/font-weights.stylex.ts'
import { lineHeights } from '@stylexblocks/ui/tokens/line-heights.stylex.ts'
import { radii } from '@stylexblocks/ui/tokens/radii.stylex.ts'
import { semanticColors } from '@stylexblocks/ui/semantic-tokens/colors.stylex.ts'
import { semanticShadows } from '@stylexblocks/ui/semantic-tokens/shadows.stylex.ts'
import { sizes } from '@stylexblocks/ui/tokens/sizes.stylex.ts'
import { spacing } from '@stylexblocks/ui/tokens/spacing.stylex.ts'

const angleSliderRoot = stylex.create({
  base: {
    display: 'inline-flex',
    flexDirection: 'column',
    alignItems: 'center',
    gap: spacing._2,
    fontSize: fontSizes.sm,
    position: 'relative',
    isolation: 'isolate',
    touchAction: 'none',
  },
})

const angleSliderRootSizes = stylex.create({
  sm: {
    '--angle-slider-size': sizes._24,
    '--angle-slider-track-size': sizes._1_5,
    '--angle-slider-thumb-size': sizes._4,
    '--angle-slider-marker-size': sizes._1,
    '--angle-slider-value-font-size': fontSizes.md,
  },
  md: {
    '--angle-slider-size': sizes._32,
    '--angle-slider-track-size': sizes._2,
    '--angle-slider-thumb-size': sizes._5,
    '--angle-slider-marker-size': sizes._1,
    '--angle-slider-value-font-size': fontSizes.xl,
  },
  lg: {
    '--angle-slider-size': sizes._40,
    '--angle-slider-track-size': sizes._2_5,
    '--angle-slider-thumb-size': sizes._6,
    '--angle-slider-marker-size': sizes._1_5,
    '--angle-slider-value-font-size': fontSizes._2xl,
  },
})

const angleSliderLabel = stylex.create({
  base: {
    fontSize: fontSizes.sm,
    lineHeight: lineHeights.sm,
    fontWeight: fontWeights.medium,
    userSelect: 'none',
    opacity: {
      default: null,
      ':is([data-disabled])': 0.5,
    },
  },
})

/**
 * The dial. The ring track and the value arc are painted on `::before`
 * (a conic gradient up to `--angle`, masked to a ring), so the thumb and
 * the centered value text stay unmasked.
 */
const angleSliderControl = stylex.create({
  base: {
    position: 'relative',
    flexShrink: 0,
    width: 'var(--angle-slider-size)',
    height: 'var(--angle-slider-size)',
    borderRadius: radii.full,
    touchAction: 'none',
    userSelect: 'none',
    cursor: {
      default: 'pointer',
      ':is([data-disabled])': 'not-allowed',
    },
    '--angle-slider-range': {
      default: colorPalette.solid,
      ':is([data-disabled])': semanticColors.borderEmphasized,
    },
    '::before': {
      content: '""',
      position: 'absolute',
      inset: 0,
      borderRadius: 'inherit',
      backgroundImage:
        'conic-gradient(var(--angle-slider-range) var(--angle, 0deg), var(--angle-slider-track) 0)',
      maskImage:
        'radial-gradient(farthest-side, transparent calc(100% - var(--angle-slider-track-size) - 0.5px), #000 calc(100% - var(--angle-slider-track-size)))',
      pointerEvents: 'none',
    },
  },
})

const angleSliderControlVariants = stylex.create({
  outline: {
    '--angle-slider-track': {
      default: `color-mix(in oklch, ${semanticColors.bgEmphasized} 72%, transparent)`,
      ':is([data-disabled])': semanticColors.bgMuted,
    },
  },
  solid: {
    '--angle-slider-track': {
      default: colorPalette.subtle,
      ':is([data-disabled])': semanticColors.bgMuted,
    },
  },
})

/**
 * A full-size layer the engine rotates by `--angle`; the knob is its
 * `::before`, sitting on the ring at 12 o'clock. Pointer input goes to the
 * control underneath.
 */
const angleSliderThumb = stylex.create({
  base: {
    position: 'absolute',
    inset: 0,
    borderRadius: radii.full,
    pointerEvents: 'none',
    outline: 'none',
    zIndex: 2,
    '--angle-slider-thumb-ring': {
      default: '0 0 0 0 transparent',
      ':focus-visible': `0 0 0 2px ${semanticColors.bg}, 0 0 0 4px ${colorPalette.focusRing}`,
    },
    '::before': {
      content: '""',
      position: 'absolute',
      boxSizing: 'border-box',
      top: 'calc(var(--angle-slider-track-size) / 2)',
      left: '50%',
      width: 'var(--angle-slider-thumb-size)',
      height: 'var(--angle-slider-thumb-size)',
      translate: '-50% -50%',
      borderRadius: radii.full,
      backgroundColor: 'var(--angle-slider-thumb-bg)',
      borderStyle: 'solid',
      borderWidth: 'var(--angle-slider-thumb-border-width)',
      borderColor: 'var(--angle-slider-thumb-border)',
      boxShadow: `var(--angle-slider-thumb-ring), ${semanticShadows.xs}`,
    },
  },
})

const angleSliderThumbVariants = stylex.create({
  outline: {
    '--angle-slider-thumb-border-width': '2px',
    '--angle-slider-thumb-border': {
      default: colorPalette.solid,
      ':is([data-disabled])': semanticColors.borderEmphasized,
    },
    '--angle-slider-thumb-bg': {
      default: semanticColors.bg,
      ':is([data-disabled])': semanticColors.borderEmphasized,
    },
  },
  solid: {
    '--angle-slider-thumb-border-width': '2px',
    '--angle-slider-thumb-border': semanticColors.bg,
    '--angle-slider-thumb-bg': {
      default: colorPalette.solid,
      ':is([data-disabled])': semanticColors.borderEmphasized,
    },
  },
})

/** Centered inside the control. */
const angleSliderValueText = stylex.create({
  base: {
    position: 'absolute',
    inset: 0,
    display: 'flex',
    alignItems: 'center',
    justifyContent: 'center',
    pointerEvents: 'none',
    fontSize: 'var(--angle-slider-value-font-size)',
    lineHeight: 1,
    fontWeight: fontWeights.semibold,
    fontVariantNumeric: 'tabular-nums',
    color: semanticColors.fg,
  },
})

const angleSliderMarkerGroup = stylex.create({
  base: {
    position: 'absolute',
    inset: 0,
    pointerEvents: 'none',
    zIndex: 1,
  },
})

/** A full-size layer the engine rotates to the marker's angle; the tick is `::before`. */
const angleSliderMarker = stylex.create({
  base: {
    position: 'absolute',
    inset: 0,
    '--angle-slider-marker-color': {
      default: semanticColors.fgSubtle,
      ':is([data-state="under-value"], [data-state="at-value"]):not([data-disabled])':
        colorPalette.contrast,
      ':is([data-disabled])': semanticColors.fgMuted,
    },
    '::before': {
      content: '""',
      position: 'absolute',
      top: 'calc(var(--angle-slider-track-size) / 2)',
      left: '50%',
      width: 'var(--angle-slider-marker-size)',
      height: 'var(--angle-slider-marker-size)',
      translate: '-50% -50%',
      borderRadius: radii.full,
      backgroundColor: 'var(--angle-slider-marker-color)',
    },
  },
})

export type AngleSliderSize = keyof typeof angleSliderRootSizes

export type AngleSliderVariant = keyof typeof angleSliderControlVariants

const angleSliderRecipe = defineSlotRecipe({
  slots: {
    root: { styles: angleSliderRoot, sizes: angleSliderRootSizes },
    label: { styles: angleSliderLabel },
    control: { styles: angleSliderControl, variants: angleSliderControlVariants },
    thumb: { styles: angleSliderThumb, variants: angleSliderThumbVariants },
    valueText: { styles: angleSliderValueText },
    markerGroup: { styles: angleSliderMarkerGroup },
    marker: { styles: angleSliderMarker },
  },
  defaultVariants: { size: "md", variant: "outline" },
});

const { withProvider, withContext } = createSlotRecipeContext(angleSliderRecipe);

const Thumb = withContext(ArkAngleSlider.Thumb, "thumb", "AngleSliderThumb");
// The machine's `valueAsDegree` reads "45deg"; show a degree sign instead.
function ValueTextNode({
  children,
  ...props
}: React.ComponentProps<typeof ArkAngleSlider.ValueText>) {
  const api = useAngleSliderContext();
  return (
    <ArkAngleSlider.ValueText {...props}>{children ?? `${api.value}°`}</ArkAngleSlider.ValueText>
  );
}

const ValueText = withContext(ValueTextNode, "valueText", "AngleSliderValueText");

function ControlNode({
  children,
  ...props
}: React.ComponentProps<typeof ArkAngleSlider.Control>) {
  return (
    <ArkAngleSlider.Control {...props}>
      {children ?? (
        <>
          <Thumb />
          <ValueText />
        </>
      )}
    </ArkAngleSlider.Control>
  );
}

/**
 * AngleSlider — Ark UI's angle-slider machine (0–359°) wearing the
 * angle-slider slot recipe. `<AngleSlider.Root variant size>` resolves the
 * recipe once; every part inherits it through context. The control paints a
 * ring track with a conic value arc up to the machine's `--angle`; the thumb
 * is a full-size layer the machine rotates, with its knob on the ring.
 * Control renders Thumb + ValueText by default; ValueText centers inside the
 * dial. Markers are ticks on the ring.
 */
export const AngleSlider = {
  Root: withProvider(ArkAngleSlider.Root, "root", "AngleSliderRoot"),
  Label: withContext(ArkAngleSlider.Label, "label", "AngleSliderLabel"),
  Control: withContext(ControlNode, "control", "AngleSliderControl"),
  Thumb,
  ValueText,
  MarkerGroup: withContext(ArkAngleSlider.MarkerGroup, "markerGroup", "AngleSliderMarkerGroup"),
  Marker: withContext(ArkAngleSlider.Marker, "marker", "AngleSliderMarker"),
  HiddenInput: ArkAngleSlider.HiddenInput,
  Context: ArkAngleSlider.Context,
};

export type AngleSliderRootProps = React.ComponentProps<typeof AngleSlider.Root>;
export type AngleSliderControlProps = React.ComponentProps<typeof AngleSlider.Control>;
export type AngleSliderThumbProps = React.ComponentProps<typeof AngleSlider.Thumb>;
export type AngleSliderMarkerProps = React.ComponentProps<typeof AngleSlider.Marker>;
```
