Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Range Slider Thresholds Form Block for React

A two-thumb slider that sets warn and critical CPU thresholds over named zones: the thumbs cannot cross, the zones and six sample readings follow, and each thumb is named by what it sets.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

Set two lines on one scale with this range slider form for React with Base UI. A compact header sits over a hairline frame with a plus mark on each corner, in two bands. The first holds a two-thumb Slider from 0 to 100 for the CPU alert thresholds: two figures above it follow the thumbs ("Warn at 70%", "Critical at 90%"), a strip under it draws the three zones, and a legend names each one (OK, Warn and Critical) with a glyph and the range it covers. The second band redraws six typed sample readings against the two lines and says "Warn from 70%, critical from 90%: 2 of 6 sample readings would alert". The thumbs can't cross and stay five points apart, and each is named by what it sets for a screen reader. The slider is drawn in the foreground colour, so the Shine Button stays the one primary. It's built from Slider, Button, Shine Button and Guides, with a CSS entrance only. For alert rules, budgets, price filters and any pair of values that bound a range.

FAQ

How do I change the scale, the gap and the readings?

Edit the constants at the top: WARN_AT and CRITICAL_AT (the saved thresholds), GAP (the least the thumbs stay apart) and READINGS (the typed samples). zoneOf decides which zone a value falls in, and the zones strip, the legend, the readings and the sentence all come from it, so a new unit or a third line only needs that helper and the legend list.

Can the thumbs cross, and is the gap the same everywhere?

No. The slider itself keeps the thumbs a gap apart. In every version the block also runs the same keepGap helper on the value it receives, so the gap holds even if a library lets two thumbs touch. A move that would close the gap is held at it, or refused outright by some libraries, and the other thumb stays put.

How are the two thumbs told apart for a screen reader?

The slider is named "CPU use thresholds" and each thumb says what it sets as its value text: "Warn at 70%" and "Critical at 90%". The figures above the track are visible text, so nothing depends on where the thumbs sit or on a colour. The arrow keys move a thumb by one, Page Up and Page Down by more, and Home and End to its ends.

Why does the foot not announce every key press?

Dragging or holding an arrow key would queue dozens of announcements. The visible line updates at once, and the polite status region says it once, 600 ms after the last change. Save thresholds is quiet while nothing changed and says "No changes to save." if pressed; Reset puts the saved values back and says so.

What stays local, and how do I connect it for real?

Nothing is saved to a monitor: Save thresholds says "Saved in this demo. Nothing was sent." and keeps the new values as the saved ones for the rest of the visit. To make it real, send the two numbers from the submit handler, validate the gap and the range on your server, and show its answer in the same status line. The sample readings are typed; feed them from your metrics.

How do I connect it to react-hook-form or TanStack Form?

Store the pair as one array value. With react-hook-form, use Controller, pass field.value to the slider and call field.onChange with the result of keepGap; a resolver can check the gap again. With TanStack Form, keep the two values in one field and validate the gap in onChange.

  • Pro

    Budget Range Slider Contact

    Quotes and estimates

    A roofing quote request as a card in a card: three kinds of job, a two-thumb budget slider that says in words what the range covers, and a short form that checks itself.

  • Pro

    Loan Payment Slider Contact

    Finance and property

    A personal-loan request for a lender: an amount slider with a tick at each $5,000 and a term to pick, a panel that works the monthly payment out as you move, and a form that checks itself.

  • Pro

    A usage-based bill calculator for a search API: a slider over monthly search volumes sits in one short band, and a meter of what the plan covers and what is billed as overage rolls the estimated bill beside it.

  • Pro

    A quantity field that sells in cases of six: typing a number snaps it up to a whole case on leaving, the keys and buttons move one case or five, and the line total is worked out in whole cents.

  • Pro

    Dinner Rating Input Form

    Numbers and pickers

    Three required star ratings for food, service and value with named steps, keys and digits, an overall worked out as the mean in half stars, and a failed press that names the missing score.

  • Pro

    Brand Colour Picker Form

    Numbers and pickers

    A brand colour field that makes a scale: a hex input and the colour picker kept in sync, eight named presets, and five derived steps by lightness, each with its hex and a copy button.