Inspector Slider

Compact settings row where the label and the live value sit inside the track: magnetic tick snapping, a rubber band when you overdrag, Shift for precision, Alt-click to reset, wheel and typed input, on a native range input for full accessibility.

Installation

Adds the component and everything it depends on to your project.

npx shadcn add https://ui.beste.co/component/r-base/inspector-slider

New here? Read the installation guide.

Usage

The import and the props worth knowing about, in one place.

import { InspectorSlider } from "@/components/beste/component/inspector-slider";

// Uncontrolled: the row keeps its own value and never re-renders while dragging
<InspectorSlider label="Blend" min={0} max={1} step={0.05} defaultValue={0.55} />

// Controlled, with a separate commit for expensive work
<InspectorSlider
  label="Amplitude"
  value={amplitude}
  onValueChange={setAmplitude}          // every drag frame
  onValueCommit={(value) => console.log("persist", value)} // once per gesture
  min={0.1}
  max={3}
  step={0.1}
/>

<InspectorSlider
  label="Opacity"
  min={0}
  max={100}
  step={1}
  unit="%"              // suffix on the default readout
  editable              // double-click the row (or press Enter) to type a value
  defaultValue={40}
/>

<InspectorSlider
  label="Radius"
  icon={Circle}         // optional leading lucide icon
  tone="outline"        // "muted" (default) | "outline" | "ghost"
  size="sm"             // "sm" | "default" | "lg"
  min={0}
  max={24}
  step={2}
  resetValue={8}        // restored by Alt-click
  ticks={[0, 8, 16, 24]} // true | false | count | explicit values
  formatValue={(value) => `${value}px`}
  defaultValue={8}
/>

// Snapping off, plain scrolling never hijacked, disabled state
<InspectorSlider label="Speed" snap={false} wheel={false} disabled min={0} max={2} />

// Takes part in a form through its underlying range input
<InspectorSlider label="Volume" name="volume" min={0} max={1} step={0.01} />

Playground

Turn the props on the right; the snippet under them is what you would write to get what you see.

Usage
import { InspectorSlider } from "@/components/beste/component/inspector-slider";

<InspectorSlider
  label="Opacity"
  defaultValue={60}
  unit="%"
/>

Keyboard and gestures

Every one of these is in the component already. They are listed because a props table cannot mention a gesture, so nothing else on this page can tell you they exist.

Arrow keysOne step. Up and Right raise it, Down and Left lower it.
Shift + ArrowTen steps, for crossing a long range without dragging.
Page Up / Page DownA tenth of the range, never less than one step.
Home / EndJump to the minimum or the maximum.
EnterTurn the readout into a field and type an exact value.
Double-click the readoutThe same, with a pointer.
Wheel over a focused rowOne step per tick, ten with Shift. Turn it off with `wheel={false}`.
Shift while draggingFine mode: the handle follows the pointer at a fraction of the distance.

Props

Read from the component's own type, so this cannot drift from what it accepts.

PropTypeDefaultDescription
label*stringLabel rendered on the left, inside the row.
iconLucideIconOptional leading icon shown before the label.
valuenumberControlled value. Pair it with `onValueChange`.
defaultValuenumberInitial value in uncontrolled mode. Falls back to `min`.
onValueChange(value: number) => voidFires on every drag frame, click, key press, wheel tick and typed edit.
onValueCommit(value: number) => voidFires once when a gesture ends and the value actually changed (pointer release, key release, end of a wheel burst, typed edit). Use it for expensive work such as persisting or re-rendering a WebGL scene.
minnumber0Minimum value.
maxnumber1Maximum value.
stepnumber0.01Smallest increment. Also drives readout precision and keyboard steps.
formatValue(value: number) => stringFormat the readout. Defaults to `value.toFixed(...)` plus `unit`.
unitstringSuffix appended to the default readout, e.g. "%", "px", "°".
ticksboolean | number | number[]trueTick marks inside the track: `true` for automatic (one per step up to 12, otherwise deciles), a count, an explicit list of values, or `false`.
snapbooleantrueMagnetically pull a click to the nearest tick. Dragging is never snapped — it stays continuous and only `step` quantizes it.
editablebooleanAllow an exact value to be typed in, by double-clicking the row or pressing Enter.
wheelbooleantrueAdjust the value with the wheel while the row has keyboard focus.
resetValuenumberValue restored by Alt-click. Falls back to `defaultValue`, then `min`.
disabledbooleanBlock every interaction and dim the row.
tone"muted" | "outline" | "ghost""muted"Surface treatment: filled (default), hairline outline, or bare until hover.
size"sm" | "default" | "lg""default"Row height preset.
namestringName of the underlying range input, so the row can take part in a form.
idstringId of the underlying range input, for an external `<label htmlFor>`.
classNamestring
labelClassNamestringClasses for the label. Needed when the row sits on something other than a theme surface — a colour ramp, say — and the muted default stops being legible. Merged onto the element, so a text colour here simply wins.
valueClassNamestringClasses for the value readout. Note that the readout brightens to `text-foreground` while the row is engaged, so an override that must hold during hover and drag has to restate itself: `"text-white group-data-[active=true]/inspector-slider:text-white"`.
aria-labelstringAccessible name. Falls back to `label`.

More Inspector components

View all Inspector

Inspector Range

Settings row for a span rather than a value: two thumbs on the row itself, the band between them filling it, and both ends of the pair read out on the right. Ticks, tones and thumb states follow inspector-slider exactly, appearing on hover.

Inspector Input

Settings row with a label on the left and a plain text field on the right, sharing the family's pill: the whole row is the label, so pressing anywhere puts the caret in the field.

Inspector Stepper

Settings row for a bounded number: minus and plus either side of a typeable value, with hold-to-repeat, Shift for coarse steps and full keyboard stepping.

Inspector Tabs

The strip that splits a settings panel into two or three questions instead of one long scroll. It is the strip and nothing else: what the tabs switch between stays in the panel's own markup, beside the state that decides it. The pill slides between equal columns, arrow keys both move and select, and a tab can carry a count of what has changed under it.

Inspector Switch

Settings row with a label on the left and a switch on the right, sharing the family's pill: the label takes the row's spare width, so a press almost anywhere toggles it.

Inspector Tracks

The columns of a grid as a list of lengths: the row shows the CSS it comes to, the editor holds one length per line with a picture of the shares above them. There is no reordering on purpose, because a track's place in the list is its place in the grid.