---
title: "Ruler Slider"
description: "Free React ruler slider: the needle stays put while the scale scrolls under it, and a flick glides to the nearest tick. Fractional steps, shadcn install."
category: "Components"
parent: "https://beui.dev/components/motion/range-slider"
publishedAt: "2026-06-24"
updatedAt: "2026-11-25"
documentation: "https://beui.dev/components/motion/range-slider/ruler"
markdown: "https://beui.dev/components/motion/range-slider/ruler.md"
license: "MIT"
---

# Ruler Slider

> Free React ruler slider: the needle stays put while the scale scrolls under it, and a flick glides to the nearest tick. Fractional steps, shadcn install.

## Install

```bash
npx shadcn@latest add @beui/range-slider-ruler
```

## Dependencies

- `clsx`
- `motion`
- `react`
- `tailwind-merge`

## Usage

### Ruler Slider usage

The needle stays put and the scale scrolls under it. A flick keeps going and settles on the nearest tick. Fractional steps read at the step's own precision.

```tsx
"use client";

import { useState } from "react";

import { RulerSlider } from "@/components/motion/range-slider-ruler";

export function RangeSliderRulerPreview() {
  const [value, setValue] = useState(72.5);

  return (
    <div className="w-full max-w-sm">
      <RulerSlider
        sound
        value={value}
        onValueChange={setValue}
        min={40}
        max={120}
        step={0.5}
        gap={12}
        majorEvery={10}
        unit="kg"
        aria-label="Weight"
      />
    </div>
  );
}
```

## API Reference

### RulerSlider

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| `gap` | `number` | `14` | No | Pixels between two steps. |
| `majorEvery` | `number` | `5` | No | Label every Nth step; those ticks are drawn tall. |
| `unit` | `string` | — | No | Unit shown next to the value. |
| `className` | `string` | — | No | Classes merged onto the root element. |
| `value` | `number` | — | No | The current value, for controlled use. |
| `defaultValue` | `number` | — | No | The initial value when uncontrolled. Default: 0 |
| `onValueChange` | `((value: number) => void)` | — | No | Called with the snapped value whenever a drag or key press changes it. |
| `min` | `number` | — | No | Lowest value on the track. Default: 0 |
| `max` | `number` | — | No | Highest value on the track. Default: 100 |
| `step` | `number` | — | No | Increment values snap to when dragging or using arrow keys. Default: 1 |
| `disabled` | `boolean` | — | No | Ignores pointer and keyboard input. Default: false |
| `aria-label` | `string` | — | No | Accessible name for the slider handle. |
| `formatValueText` | `((value: number) => string)` | — | No | Announced instead of the raw number — pass one when the value carries a unit or a suffix ("72.5 kg", "35%"); a bare number needs no valueText. |
| `sound` | `boolean` | — | No | Play a tiny tick per step, higher toward the max. Off by default; a `SoundProvider` can mute it app-wide. |

## More in Range Slider

- [Inline Slider](https://beui.dev/components/motion/range-slider/inline.md)
- [Range Slider](https://beui.dev/components/motion/range-slider/stepped.md)
- [Fluid Slider](https://beui.dev/components/motion/range-slider/fluid.md)
- [Wave Slider](https://beui.dev/components/motion/range-slider/wave.md)
- [Bubble Slider](https://beui.dev/components/motion/range-slider/bubble.md)

## Source

- Registry detail: https://beui.dev/r/range-slider-ruler
- Raw source: https://beui.dev/r/range-slider-ruler/raw
- GitHub: https://github.com/starc007/ui-components
