Components
npx shadcn@latest add https://21st.dev/r/originui/sliderLoading preview...
"use client";
import { useSliderWithInput } from "@/components/hooks/use-slider-with-input";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { Slider } from "@/components/ui/slider";
function Component() {
const minValue = 0;
const maxValue = 100;
const initialValue = [25];
const {
sliderValue,
inputValues,
validateAndUpdateValue,
handleInputChange,
handleSliderChange,
} = useSliderWithInput({ minValue, maxValue, initialValue });
return (
<div className="space-y-3 min-w-[300px]">
<Label>Slider with input</Label>
<div className="flex items-center gap-4">
<Slider
className="grow"
value={sliderValue}
onValueChange={handleSliderChange}
min={minValue}
max={maxValue}
aria-label="Slider with input"
/>
<Input
className="h-8 w-12 px-2 py-1"
type="text"
inputMode="decimal"
value={inputValues[0]}
onChange={(e) => handleInputChange(e, 0)}
onBlur={() => validateAndUpdateValue(inputValues[0], 0)}
onKeyDown={(e) => {
if (e.key === "Enter") {
validateAndUpdateValue(inputValues[0], 0);
}
}}
aria-label="Enter value"
/>
</div>
</div>
);
}
export { Component };
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...