Skip to content

BbSlider

Choose an approximate bounded value, paired with exact entry when precision matters.

import { BbSlider } from 'bitboss-ui';

On this page

Use it for

Use BbSlider when position within a known interval carries meaning.

Use something else when

Also see: Validated forms.

Passthrough

Hover or tap a part to outline it. The toggles turn on loading, errors and warnings where the component has them; only parts get a row.

Guidance while the control is focused.

Set an exact spending limit

When the amount has consequences, bind the slider and number field to the same ref.

/ month

min, max, and step are hard invariants. Invalid bounds or a non-positive step throw at mount. A value from an API must be converted to a number before binding.

Filter a range

Set multiple and bind an array: a bare multiple gives two thumbs, :multiple="3" three.

Price €100 to €500
17 of 26 products

The array holds one value per thumb, always sorted, so price[0] is the lower end. Thumbs cross: drag one past its neighbour and they trade places. Start unset with [] or null (the thumbs spread evenly and nothing is committed until the first move); a number, or an array of another length, throws at mount. v-model types itself from the mode: number alone, [number, number] for a bare multiple, number[] for more thumbs.

Named stops

When the scale is a list rather than a range of numbers, pass items: the thumb lands only on those stops, spaced evenly in list order.

15 min1 h4 h1 day1 week
Stored as 240 minutes

Each stop is a string, a number or { value, label }: v-model holds the value, while the tick and thumb slots and screen readers get the label. items replaces min, max and step (setting them too throws), and a model outside the list throws.

Readout, ticks, and keyboard

The component has no built-in numeric readout. Show the model beside the track or through the thumb slot (with multiple, every thumb renders it: tell them apart by index).

12345

ticks positions the tick slot and draws no marks by itself. Raise max-precision when step is finer than 0.01.

Playback volume Meeting room speaker
60%

Arrow keys move one step, Page keys ten, and Home/End reach the bounds; every key and both stepper callbacks land on the step grid. When max is off that grid, the top is the last grid point (0–10 by 3 stops at 9). The stepper callbacks are inert with multiple, and each slot's disabled says when its side would do nothing (at a bound, or on a disabled, readonly or multi-thumb slider), so the buttons bind it instead of comparing to min and max. A slot that holds both buttons reads decreaseDisabled and increaseDisabled instead. Save in value-commit, not in update:modelValue, which fires on every frame of a drag: it fires once a drag is released and on each keyboard or stepper step, only when the value changed (how it works).

Coming from v2thumb-translate → disable-thumb-translate

:thumb-translate="false" became disable-thumb-translate with inverted polarity.

Messages and locked values

Say why a value is risky, invalid or locked: warnings for a value you accept with a caveat, errors for one you refuse, description or hint for a lock.

Above 80 the files grow faster than the detail.
Production services need at least two.
Set by your plan. Upgrade to raise it.

Prefer readonly for a locked value that people still need to inspect; disabled removes the thumb from the tab order.

To lock one end of a range, pass disabled an array, one entry per value in sorted order: :disabled="[true]" locks the lower thumb, for a window whose start has passed. The other thumbs stop at its value, and the field still posts every value.

label-mode takes outside or inside only (a floating default set for the whole app falls back to outside here, without a warning).

Submit it with a form

In a BbForm the slider joins the form by its name and needs no v-model. Use rules for what min and max cannot say.

08:0012:0016:0020:00

Drag the two ends closer than two hours and submit to see the rule stop the booking. A classic <form> post gets one field per value: window=10&window=14 with multiple (name it window[] for Laravel), nothing at all for a null value. A slider that sits in a form without being its data, such as a zoom level, takes formless to stay out of the form's data and validation.

Paint zones on the rail

The thumbs cut the rail into segments; fill picks which ones get a coloured bar. fill="segments" paints every one, and a pt:bar function colours each by item.index.

CPU alert levels warn at 60% · page at 85%
Green is normal, amber warns the team, red pages whoever is on call.

fill="inverted" paints the rest instead: from the thumb to the end, or outside the two thumbs ("outside these hours"). The tick slot and a pt:tick function get the segment a tick sits on, so marks can match their zone.

Rail, bar, and ticks

The colours are two locals on pt:box: --accent paints the bar and the thumb's halo, --track-color the rail.

0 1k 2k 3k 4k 5k

pt:track reaches the rail itself, pt:bar the coloured span, and pt:tick:in-range only the marks under that span. The hasValue state is on while a value is set (pt:thumb:has-value), so an unset slider can look unset. --track sets the rail's thickness, --thumb the handle's size, and --r the rounding of the rail and of the box.

In inside label mode the box wears the field look through the same words as the other fields: --bg, --bw, --border-color, --r, --elev, --ring-size with --ring-color, and --px/--py. Its focus ring turns danger or warning with the field's state, so recolour the resting border with pt:box="[--border-color:…]" rather than a border-* utility, which would hide the state.

Coming from v2color → --accent

The v2 color prop is gone: set --accent (and --track-color) on pt:box, as above.