Skip to main content

Slider with unit

Compont field Ranger slider (polaris) kèm theo input hiển thị value và đơn vị

Ví dụ

import { SliderWithUnit } from '@xobuilder/ui';

export const Demo = () => {
const [value, setValue] = useState<SliderWithUnitValue>({
value: 0,
unit: 'px',
});

const handleChange = (valueUpdate: SliderWithUnitValue) => {
console.log(valueUpdate);
setValue(valueUpdate);
};

return (
<SliderWithUnit
value={value}
placeholder="auto"
max={100}
min={0}
step={1}
haveUnit={true}
options={['px', 'em']}
onChange={handleChange}
/>
)
}

SliderWithUnit Props

NameTypeDefaultDescription
valuenumberGiá trị của field
placeholderstringPlaceholder của text field
maxnumber-Giá trị max
minnumber-Giá trị min
stepnumber-Step của slider
haveUnitboolean-Field có unit hay không
unitstring-Đơn vị của field
optionsstring[]-Các option unit có thể thay đổi
onChange`(value: numberstringRangeSliderValue) => void`