Skip to content

NewMCP server for your coding agent. Set it up ›

Nexus UI
Get Pro

Slosh Slider, animated React component

  • Pro
  • Inputs & Controls
  • Spring

A slider whose value has mass: the rigid handle stays under your finger while the liquid fill lags behind, leans with the speed you drag at and sloshes back and forth before it settles.

Ticks every 5% as you drag, click or use the keys. Sound is off on this site until you switch it on.

Props

PropTypeDefaultWhat it does
label"Volume"Label above the track; also the slider's accessible name.
defaultValue55Starting value, 0 to 100.
accent"#0071e3"Liquid colour and focus ring.
onChange—Called with the rounded value (0 to 100) whenever it changes.
autoplayfalseThrows the handle to a series of values until someone touches it.
enableSoundtruePlays 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. 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 creates components.json and the cn() helper in src/lib/utils.ts:

    npx shadcn@latest init -d

    Starting from nothing? The Quick Start walks through the whole thing.

  2. 2

    Connect the registry with your API key

    Slosh Slider is a Pro item, so the CLI has to send your API key. Do this once per project:

    1. Create a key at nexus-ui.com/dashboard/api-key. Copy it straight away: it starts with nxs_ and is shown only once.
    2. In your project root, next to package.json, create a file named .env.local with this line, using your own key:
      NEXUS_API_KEY=nxs_your_key_here
    3. Open components.json and 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}"
          }
        }
      }

How Slosh Slider works

A slider whose value has mass. The handle is rigid and stays exactly under at and sloshes back and forth before it settles.

The source, the install command and the build prompt come with Pro.

Slosh Slider questions

How do I install Slosh Slider?

Run `npx shadcn@latest add @nexus-labs/slosh-slider`. It installs framer-motion. Slosh Slider 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 read and set the value?

`defaultValue` sets the start, 0 to 100, default 55. `onChange` is called with the rounded value whenever it changes, following the handle rather than the lagging liquid. There is no controlled `value` prop.

How do I change the label and color?

`label` sets the text above the track and the slider's accessible name, default "Volume". `accent` colors the liquid and the focus ring, default `#0071e3`. The track is a fixed 300px wide.

Does it work with the keyboard?

Yes. The track is a `role="slider"` with `aria-valuenow`. Arrow keys move the value by 5%, and Home and End jump to 0 and 100.

How does the sloshing work?

The handle follows the pointer exactly. The liquid is an SVG path that chases it on a loose spring and leans with its speed, up to 26px, then settles. It uses Framer Motion springs and velocity, not a physics library.

Does it make sound, and how do I turn it off?

Ticks every 5% as you drag, click or use the keys. 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.