Number slider

Linked slider and numeric input – drag the track or type a value.

Install

npx shadcn@latest add https://substrate.georgedrury.co.uk/r/number-slider

Examples

Default

%
px
"use client"

import { useState } from "react"

Props

PropTypeDefaultDescription
valuenumber—Current value
onChange(value: number) => void—Called when the value changes
onStart() => void—Called once at the start of a gesture. Useful for undo snapshots.
minnumber0Minimum value
maxnumber100Maximum value
stepnumber1Increment per step
shiftStepnumber10Increment when Shift is held (number input only)
precisionnumber2Decimal places for display
labelstring—Label on the number input (with drag-to-scrub)
suffixstring—Trailing text (e.g. %, px)
disabledboolean—Disables both slider and input