cal.pub0.org/apps/web/components/Slider.tsx

28 lines
717 B
TypeScript
Raw Normal View History

import * as SliderPrimitive from "@radix-ui/react-slider";
import React from "react";
2021-08-13 07:59:48 +00:00
const Slider = ({
value,
label,
changeHandler,
...props
}: Omit<SliderPrimitive.SliderProps, "value"> & {
value: number;
label: string;
changeHandler: (value: number) => void;
}) => (
<SliderPrimitive.Root
className="slider mt-2"
value={[value]}
2021-08-13 07:59:48 +00:00
aria-label={label}
onValueChange={(value: number[]) => changeHandler(value[0] ?? value)}
{...props}>
<SliderPrimitive.Track className="slider-track">
<SliderPrimitive.Range className="slider-range" />
</SliderPrimitive.Track>
<SliderPrimitive.Thumb className="slider-thumb" />
2021-08-13 07:59:48 +00:00
</SliderPrimitive.Root>
);
export default Slider;