Documentation
Buttons
Toggle Group

Toggle Group

Playground

import { ToggleGroup, ToggleGroupProps } from '@creation-ui/react'
import { mdiAbacus, mdiAlarm, mdiBedQueenOutline } from '@mdi/js'
import { Icon } from '@mdi/react'
 
const options = [
  { value: '1', label: <Icon path={mdiAbacus} /> },
  { value: '2', label: <Icon path={mdiAlarm} /> },
  { value: '3', label: <Icon path={mdiBedQueenOutline} /> },
]
 
export const ToggleGroupExample = ({ size }: ToggleGroupProps) => {
  const [value, setValue] = useState<string>('1')
 
  return <ToggleGroup label='Select option' size={'sm'} options={options} value={value} onChange={setValue} />
}

Component API

Props of ToggleGroup component.

PropDefaultDescription
label
string

The label of the toggle group

options
ToggleGroupOption[]

Options to select, see ToggleGroupOption below

required
boolean

Is the toggle group marked as required?

onChange
(value: T = string): void;

Callback when the value changes. Type of value is inherited from the options - string is default

Props of ToggleGroupOption component.

PropDefaultDescription
label
string | React.ReactNode

The title of the option

value
string

The value of the option

disabled
boolean

Is option disabled?