-
-
Notifications
You must be signed in to change notification settings - Fork 450
/
Copy pathRangeSlider.tsx
31 lines (26 loc) · 1.01 KB
/
RangeSlider.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import type { ComponentProps } from 'react';
import { forwardRef } from 'react';
import { twMerge } from 'tailwind-merge';
import { mergeDeep } from '../../helpers/merge-deep';
import { getTheme } from '../../theme-store';
import type { DeepPartial } from '../../types';
import type { FlowbiteTextInputSizes } from '../TextInput';
export interface FlowbiteRangeSliderTheme {
base: string;
sizes: FlowbiteTextInputSizes;
}
export interface RangeSliderProps extends Omit<ComponentProps<'input'>, 'ref' | 'type'> {
sizing?: keyof FlowbiteTextInputSizes;
theme?: DeepPartial<FlowbiteRangeSliderTheme>;
}
export const RangeSlider = forwardRef<HTMLInputElement, RangeSliderProps>(
({ className, sizing = 'md', theme: customTheme = {}, ...props }, ref) => {
const theme = mergeDeep(getTheme().rangeSlider, customTheme);
return (
<>
<input ref={ref} type="range" className={twMerge(theme.base, theme.sizes[sizing], className)} {...props} />
</>
);
},
);
RangeSlider.displayName = 'RangeSlider';