Skip to main content

Button group

Button group cho phép ta lựa chọn một trong nhiều options giống <Select> nhưng có UI hiển thị dang inline

Ví dụ

import { ButtonGroup, ButtonGroupOption } from '@xobuilder/ui';

export const Demo = () => {
const [value, setValue] = useState<string>('');

const options: ButtonGroupOption[] = [
{ value: 'center', label: 'Center' },
{ value: 'left', label: 'Left' },
{ value: 'right', label: 'Right' },
]
return (
<ButtonGroup value={value} options={options} onChange={setValue} />
)
}

ButtonGroupOption Props

NameTypeDefaultDescription
valuestring | string[]-Value của button option
iconIconProps['name']-Icon của button option
labelstring-Label của button option

ButtonGroupProps Props

NameTypeDefaultDescription
optionsButtonGroupOption[]-List options của button group
valuestring-Value của button group
tooltipEnabledbooleanfalseNếu tooltip được bật thì label sẽ hiển thị theo kiểu tooltip
onChange(value: string) => void-Callback thay đổi giá trị