Bending Rail, animated React component
- Pro
- Inputs & Controls
- Spring
A slider whose rail follows the knob. Pull the knob off the groove and the rail bends toward it while a ghost knob keeps the value; let go and it twangs straight on a spring.
Gives a soft latch click when you grab the knob and ticks as the value changes. Sound is off on this site until you switch it on.
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| label | string | "Volume" | Label shown above the rail and used as the slider's accessible name. |
| min | number | 0 | Lowest value. |
| max | number | 100 | Highest value. |
| defaultValue | number | 40 | Starting value. |
| unit | string | "%" | Suffix shown after the value. |
| accent | string | "#0071e3" | Colour of the filled run, the tether and the ghost knob. |
| onChange | (v: number) => void | — | Called whenever the rounded value changes. |
| autoplay | boolean | false | Tugs the knob around by itself until someone grabs it. |
| enableSound | boolean | true | Plays interface sounds on interaction. They follow the sound switch (setSoundsEnabled, on by default) and stay silent on hover. Autoplay makes the same sounds once the visitor has used the page. Pass false to silence this component. |
Add it to your project
- 1
Set up your project once
You need a Next.js project with Tailwind CSS and the
@/import alias. In its root folder, run this once. It createscomponents.jsonand thecn()helper insrc/lib/utils.ts:npx shadcn@latest init -d
Starting from nothing? The Quick Start walks through the whole thing.
- 2
Connect the registry with your API key
Bending Rail is a Pro item, so the CLI has to send your API key. Do this once per project:
- Create a key at nexus-ui.com/dashboard/api-key. Copy it straight away: it starts with
nxs_and is shown only once. - In your project root, next to
package.json, create a file named.env.localwith this line, using your own key:NEXUS_API_KEY=nxs_your_key_here
- Open
components.jsonand add this entry inside the outermost braces, next to"aliases". Leave{name}and${NEXUS_API_KEY}exactly as written; the CLI fills them in:"registries": { "@nexus-labs": { "url": "https://www.nexus-ui.com/api/registry/{name}", "headers": { "Authorization": "Bearer ${NEXUS_API_KEY}" } } }
- Create a key at nexus-ui.com/dashboard/api-key. Copy it straight away: it starts with
How Bending Rail works
A slider whose rail follows the knob. Pull the knob off the groove and the value. Let go and the rail twangs straight on a spring.
The source, the install command and the build prompt come with Pro.
Bending Rail questions
How do I install Bending Rail?
Run `npx shadcn@latest add @nexus-labs/bending-rail`. It installs framer-motion. Bending Rail is a Pro component, so it needs a Pro plan and an API key; key setup is on the CLI docs page (/docs/cli).
How do I set the label, range and starting value?
Use `label` (default "Volume"), `min` (0), `max` (100), `defaultValue` (40) and `unit` ("%"). `onChange` is called whenever the rounded value changes. It is uncontrolled, so there is no `value` prop.
How does the rail bend?
Drag the knob up or down off the groove and the rail bends toward it, with the pull damped and capped. A dashed ghost knob stays on the groove at the real value. Release and the rail springs straight. It is drawn with SVG paths.
What keyboard keys does it support?
The knob is a button with `role="slider"` and ARIA min, max and now values. Arrow Right or Up adds 1 and Arrow Left or Down subtracts 1; holding Shift changes it by 10. `accent` also colours the focus ring.
Does it make sound, and how do I turn it off?
Gives a soft latch click when you grab the knob and ticks as the value changes. Sounds are synthesised with the Web Audio API, so there are no audio files, and they only play after a click or key press. Pass `enableSound={false}` to silence this component, or call `setSoundsEnabled(false)` from `@/lib/ui-sounds` to switch every sound off at once. The CLI installs `@/lib/ui-sounds` with the component.

