Elastic slider
A bounded slider with elastic endpoint stretch, rigid content, and interruptible settling.
Preview
Elastic Slider
HorizontalControls
Drag past either end. Arrow keys adjust the value. Release to commit.
Installation
bunx shadcn@latest add @modulo/elastic-sliderRequires an active Modulo key and a project configured for shadcn.
Registry setup
Set MODULO_REGISTRY_KEY to your key. Add this registry entry to components.json.
{
"registries": {
"@modulo": {
"url": "<registry-url>/r/{name}.json",
"headers": {
"Authorization": "Bearer ${MODULO_REGISTRY_KEY}"
}
}
}
}Usage
import { ElasticSlider } from "@/components/elastic-slider/ElasticSlider";
export default function Example() {
return <ElasticSlider label="Brightness" defaultValue={65} orientation="vertical" />;
}React and scoped CSS. No animation package required.
Registry JSONDownload thumbnailDownload preview GIFDownload preview videoInteraction
Drag horizontally or vertically. The value stays within its bounds while the shell stretches at either end. Labels, content, and input targets keep their shape.
Arrow keys adjust one step. Page Up and Page Down adjust ten steps. Home and End select the bounds. Step rounding starts at the minimum.
Changes arrive during adjustment. A successful pointer release or keyboard release commits the requested value. Cancellation settles the shell without a commit. Controlled values remain owned by the parent.
Reduced motion preserves value adjustment without elastic stretching. Preference changes, hidden tabs, and unmounting stop pending animation and replay.
API
| Prop | Type | Default |
|---|---|---|
labelVisible and accessible name for the value. | string | Required |
value / defaultValueUse value with onValueChange for controlled state, or defaultValue for local state. | number | min |
min / maxFinite ordered semantic bounds. | number | 0 / 100 |
stepValue increment counted from min, or continuous pointer values with any. | number | "any" | 1 |
orientationInput direction and shell layout. | "horizontal" | "vertical" | "horizontal" |
disabledBlocks pointer and keyboard changes. | boolean | false |
reducedMotionRequests a still alternate path. The system preference also applies. | boolean | false |
onValueChangeBounded normalized value requests. Required with controlled value. | (value: number) => void | Optional |
onValueCommitSuccessful user adjustment. Cancellation does not commit. | (value: number) => void | Optional |
formatValueFormats the displayed and accessible value. | (value: number) => string | Optional |
childrenRigid decorative content outside shell deformation. | ReactNode | Optional |
onReadyController on mount and null on cleanup. Keep callback stable. | (controller | null) => void | Optional |
Controller methods
update(options) updates the existing instance. snapshot() reports accepted value, pending proposal, raw and rendered stretch, velocity, gesture phase, and runtime status.
replay() runs finite simulated input for media. User input cancels it. destroy() releases the instance's listeners, observers, timers, and frames. React calls it on unmount.
Source
Checking source access...