Skip to main content

Choice with device

Component này là dạng bọc 1 component khác và tạo cho nó phần action responsive theo device

Ví dụ

import { Choice } from '@xobuilder/ui';
import { Editor } from '@xobuilder/editor';

export const Demo = () => {
const { setDevice } = Editor.useDevice();

const [deviceList, setDeviceList] = useState<DeviceValue[]>(['desktop']);

const handleRemove = (mode: DeviceValue) => {
setDeviceList(deviceList.filter(item => item !== mode));
};

return (
<Choice
title="Sample title"
helpText="Sample description"
primaryComponent={<Choice.Device deviceList={deviceList} deviceOmit={[]} onChange={setDevice} onRemove={handleRemove} />}
>
<p>Children here...</p>
</Choice>
);
};

Props

NameTypeDefaultDescription
titlestring-Title của wrapper
helpTextstring-Help text của wrapper
primaryComponentReact.ReactNode-Primary component của Choice
childrenReact.ReactNode-Children hiển thị bên trong wrapper