Choose a single or multiple formatting options.
import { useState } from 'react';
import { ToggleGroup } from '@vrum/ui';
import { ToggleGroupItem } from '@vrum/ui';
export default function Demo() {
const [value, setValue] = useState(["bold"]);
return (
<ToggleGroup
type={"multiple"}
value={value}
variant={"outline"}
size={"md"}
spacing={4}
aria-label={"Formatting"}
onValueChange={setValue}
>
<ToggleGroupItem value="bold" aria-label="Bold">B</ToggleGroupItem>
<ToggleGroupItem value="italic" aria-label="Italic">I</ToggleGroupItem>
<ToggleGroupItem value="underline" aria-label="Underline">U</ToggleGroupItem>
</ToggleGroup>
);
}Copy code| Prop | Type | Default | Description |
|---|---|---|---|
type* | "multiple" | "single" | none | type configuration. |
value | string | string[] | none | Controlled value; connect the callback to application state. |
defaultValue | string | string[] | none | The value of the item that is pressed when initially rendered. Use `defaultValue` if you do not need to control the state of a toggle group. The value of the items that are pressed when initially rendered. Use `defaultValue` if you do not need to control the state of a toggle group. |
onValueChange | ((value: string) => void) | ((value: string[]) => void) | none | The callback that fires when the value of the toggle group changes. The callback that fires when the state of the toggle group changes. |
disabled | boolean | none | Whether the group is disabled from user interaction. |
rovingFocus | boolean | none | Whether the group should maintain roving focus of its buttons. |
loop | boolean | none | loop configuration. |
orientation | Orientation | none | orientation configuration. |
dir | Direction | none | dir configuration. |
asChild | boolean | none | as child configuration. |
defaultChecked | boolean | none | default checked configuration. |
autoFocus | boolean | none | auto focus configuration. |
className | string | none | Additional CSS classes. |
id | string | none | id configuration. |
style | CSSProperties | none | Inline style overrides. |
aria-invalid | boolean | "false" | "true" | "grammar" | "spelling" | none | Indicates the entered value does not conform to the format expected by the application. |
aria-label | string | none | aria-label configuration. |
children | ReactNode | none | Content rendered inside the component. |
onFocus | FocusEventHandler<HTMLDivElement> | none | on focus configuration. |
onBlur | FocusEventHandler<HTMLDivElement> | none | on blur configuration. |
onChange | ChangeEventHandler<HTMLDivElement, Element> | none | Called when the input value changes. |
onSubmit | SubmitEventHandler<HTMLDivElement> | none | Called when the form is submitted. |
onKeyDown | KeyboardEventHandler<HTMLDivElement> | none | on key down configuration. |
onClick | MouseEventHandler<HTMLDivElement> | none | Called when the control is activated. |
onSelect | ReactEventHandler<HTMLDivElement> | none | on select configuration. |
variant | "outline" | "default" | "default" | Visual appearance within the Vrum design system. |
size | "sm" | "md" | "lg" | "md" | Size of the component. |
spacing | number | 4 | spacing configuration. |
| Prop | Type | Default | Description |
|---|---|---|---|
asChild | boolean | none | as child configuration. |
disabled | boolean | none | Disable user interaction. |
name | string | none | name configuration. |
type | "submit" | "reset" | "button" | none | type configuration. |
value* | string | none | A string value for the toggle group item. All items within a toggle group should use a unique value. |
defaultChecked | boolean | none | default checked configuration. |
defaultValue | string | number | readonly string[] | none | Initial value for an uncontrolled component. |
autoFocus | boolean | none | auto focus configuration. |
className | string | none | Additional CSS classes. |
id | string | none | id configuration. |
style | CSSProperties | none | Inline style overrides. |
aria-invalid | boolean | "false" | "true" | "grammar" | "spelling" | none | Indicates the entered value does not conform to the format expected by the application. |
aria-label | string | none | Defines a string value that labels the current element. |
children | ReactNode | none | Content rendered inside the component. |
onFocus | FocusEventHandler<HTMLButtonElement> | none | on focus configuration. |
onBlur | FocusEventHandler<HTMLButtonElement> | none | on blur configuration. |
onChange | ChangeEventHandler<HTMLButtonElement, Element> | none | Called when the input value changes. |
onSubmit | SubmitEventHandler<HTMLButtonElement> | none | Called when the form is submitted. |
onKeyDown | KeyboardEventHandler<HTMLButtonElement> | none | on key down configuration. |
onClick | MouseEventHandler<HTMLButtonElement> | none | Called when the control is activated. |
onSelect | ReactEventHandler<HTMLButtonElement> | none | on select configuration. |