ToggleButton
Props
API reference for ToggleButton. For usage examples, see the React tab.
ToggleButton
| Name | Type | Default |
|---|---|---|
| children | ChildrenOrFunction<ToggleButtonRenderProps> | — |
The children of the component. A function may be provided to alter the children based on component state. | ||
| defaultSelected | boolean | — |
Whether the element should be selected (uncontrolled). | ||
| isDisabled | boolean | — |
Whether the button is disabled. | ||
| isSelected | boolean | — |
Whether the element should be selected (controlled). | ||
| size | "lg" | "md" | "sm" | md |
Size of the ToggleButton. Ignored when rendered inside a | ||
| variant | "icon" | "text" | icon |
Icon variant is icon only where text accepts a string and icon. | ||
| Name | Type | Default |
|---|---|---|
| aria-controls | string | — |
Identifies the element (or elements) whose contents or presence are controlled by the current element. | ||
| aria-describedby | string | — |
Identifies the element (or elements) that describes the object. | ||
| aria-details | string | — |
Identifies the element (or elements) that provide a detailed, extended description for the object. | ||
| aria-disabled | "false" | "true" | boolean | — |
Indicates whether the element is disabled to users of assistive technology. | ||
| aria-expanded | "false" | "true" | boolean | — |
Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed. | ||
| aria-haspopup | "dialog" | "false" | "grid" | "listbox" | "menu" | "tree" | "true" | boolean | — |
Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element. | ||
| aria-label | string | — |
Defines a string value that labels the current element. | ||
| aria-labelledby | string | — |
Identifies the element (or elements) that labels the current element. | ||
| aria-pressed | "false" | "mixed" | "true" | boolean | — |
Indicates the current "pressed" state of toggle buttons. | ||
| id | Key | — |
When used in a ToggleButtonGroup, an identifier for the item in | ||
| Name | Type | Default |
|---|---|---|
| autoFocus | boolean | — |
Whether the element should receive focus on render. | ||
| dir | string | — |
| excludeFromTabOrder | boolean | — |
Whether to exclude the element from the sequential tab order. If true, the element will not be focusable via the keyboard by tabbing. This should be avoided except in rare scenarios where an alternative means of accessing the element or its functionality via the keyboard is available. | ||
| hidden | boolean | — |
| inert | boolean | — |
| lang | string | — |
| preventFocusOnPress | boolean | — |
Whether to prevent focus from moving to the button when pressing it. Caution, this can make the button inaccessible and should only be used when alternative keyboard interaction is provided, such as ComboBox's MenuTrigger or a NumberField's increment/decrement control. | ||
| render | DOMRenderFunction<"button", ToggleButtonRenderProps> | — |
Overrides the default DOM element with a custom render function. This allows rendering existing components with built-in styles and behaviors such as router links, animation libraries, and pre-styled components. Requirements:
| ||
| slot | string | null | — |
A slot name for the component. Slots allow the component to receive props from a parent component. An explicit | ||
| suppressHydrationWarning | boolean | — |
A React-only flag that suppresses the warning React normally logs when an element's server-rendered content doesn't match the client render during hydration. See React docs (opens in new tab). | ||
| translate | "no" | "yes" | — |
| Name | Type | Default |
|---|---|---|
| onAnimationEnd | AnimationEventHandler<HTMLDivElement> | — |
| onAnimationEndCapture | AnimationEventHandler<HTMLDivElement> | — |
| onAnimationIteration | AnimationEventHandler<HTMLDivElement> | — |
| onAnimationIterationCapture | AnimationEventHandler<HTMLDivElement> | — |
| onAnimationStart | AnimationEventHandler<HTMLDivElement> | — |
| onAnimationStartCapture | AnimationEventHandler<HTMLDivElement> | — |
| onAuxClick | MouseEventHandler<HTMLDivElement> | — |
| onAuxClickCapture | MouseEventHandler<HTMLDivElement> | — |
| onBlur | ((e: FocusEvent<Element, Element>) => void) | — |
Handler that is called when the element loses focus. | ||
| onChange | ((isSelected: boolean) => void) | — |
Handler that is called when the element's selection state changes. | ||
| onClickCapture | MouseEventHandler<HTMLDivElement> | — |
| onContextMenu | MouseEventHandler<HTMLDivElement> | — |
| onContextMenuCapture | MouseEventHandler<HTMLDivElement> | — |
| onDoubleClick | MouseEventHandler<HTMLDivElement> | — |
| onDoubleClickCapture | MouseEventHandler<HTMLDivElement> | — |
| onFocus | ((e: FocusEvent<Element, Element>) => void) | — |
Handler that is called when the element receives focus. | ||
| onFocusChange | ((isFocused: boolean) => void) | — |
Handler that is called when the element's focus status changes. | ||
| onGotPointerCapture | PointerEventHandler<HTMLDivElement> | — |
| onGotPointerCaptureCapture | PointerEventHandler<HTMLDivElement> | — |
| onHoverChange | ((isHovering: boolean) => void) | — |
Handler that is called when the hover state changes. | ||
| onHoverEnd | ((e: HoverEvent) => void) | — |
Handler that is called when a hover interaction ends. | ||
| onHoverStart | ((e: HoverEvent) => void) | — |
Handler that is called when a hover interaction starts. | ||
| onKeyDown | ((e: KeyboardEvent) => void) | — |
Handler that is called when a key is pressed. | ||
| onKeyUp | ((e: KeyboardEvent) => void) | — |
Handler that is called when a key is released. | ||
| onLostPointerCapture | PointerEventHandler<HTMLDivElement> | — |
| onLostPointerCaptureCapture | PointerEventHandler<HTMLDivElement> | — |
| onMouseDown | MouseEventHandler<HTMLDivElement> | — |
| onMouseDownCapture | MouseEventHandler<HTMLDivElement> | — |
| onMouseEnter | MouseEventHandler<HTMLDivElement> | — |
| onMouseLeave | MouseEventHandler<HTMLDivElement> | — |
| onMouseMove | MouseEventHandler<HTMLDivElement> | — |
| onMouseMoveCapture | MouseEventHandler<HTMLDivElement> | — |
| onMouseOut | MouseEventHandler<HTMLDivElement> | — |
| onMouseOutCapture | MouseEventHandler<HTMLDivElement> | — |
| onMouseOver | MouseEventHandler<HTMLDivElement> | — |
| onMouseOverCapture | MouseEventHandler<HTMLDivElement> | — |
| onMouseUp | MouseEventHandler<HTMLDivElement> | — |
| onMouseUpCapture | MouseEventHandler<HTMLDivElement> | — |
| onPointerCancel | PointerEventHandler<HTMLDivElement> | — |
| onPointerCancelCapture | PointerEventHandler<HTMLDivElement> | — |
| onPointerDown | PointerEventHandler<HTMLDivElement> | — |
| onPointerDownCapture | PointerEventHandler<HTMLDivElement> | — |
| onPointerEnter | PointerEventHandler<HTMLDivElement> | — |
| onPointerLeave | PointerEventHandler<HTMLDivElement> | — |
| onPointerMove | PointerEventHandler<HTMLDivElement> | — |
| onPointerMoveCapture | PointerEventHandler<HTMLDivElement> | — |
| onPointerOut | PointerEventHandler<HTMLDivElement> | — |
| onPointerOutCapture | PointerEventHandler<HTMLDivElement> | — |
| onPointerOver | PointerEventHandler<HTMLDivElement> | — |
| onPointerOverCapture | PointerEventHandler<HTMLDivElement> | — |
| onPointerUp | PointerEventHandler<HTMLDivElement> | — |
| onPointerUpCapture | PointerEventHandler<HTMLDivElement> | — |
| onPress | ((e: PressEvent) => void) | — |
Handler that is called when the press is released over the target. | ||
| onPressChange | ((isPressed: boolean) => void) | — |
Handler that is called when the press state changes. | ||
| onPressEnd | ((e: PressEvent) => void) | — |
Handler that is called when a press interaction ends, either over the target or when the pointer leaves the target. | ||
| onPressStart | ((e: PressEvent) => void) | — |
Handler that is called when a press interaction starts. | ||
| onPressUp | ((e: PressEvent) => void) | — |
Handler that is called when a press is released over the target, regardless of whether it started on the target or not. | ||
| onScroll | UIEventHandler<HTMLDivElement> | — |
| onScrollCapture | UIEventHandler<HTMLDivElement> | — |
| onTouchCancel | TouchEventHandler<HTMLDivElement> | — |
| onTouchCancelCapture | TouchEventHandler<HTMLDivElement> | — |
| onTouchEnd | TouchEventHandler<HTMLDivElement> | — |
| onTouchEndCapture | TouchEventHandler<HTMLDivElement> | — |
| onTouchMove | TouchEventHandler<HTMLDivElement> | — |
| onTouchMoveCapture | TouchEventHandler<HTMLDivElement> | — |
| onTouchStart | TouchEventHandler<HTMLDivElement> | — |
| onTouchStartCapture | TouchEventHandler<HTMLDivElement> | — |
| onTransitionCancel | TransitionEventHandler<HTMLDivElement> | — |
| onTransitionCancelCapture | TransitionEventHandler<HTMLDivElement> | — |
| onTransitionEnd | TransitionEventHandler<HTMLDivElement> | — |
| onTransitionEndCapture | TransitionEventHandler<HTMLDivElement> | — |
| onTransitionRun | TransitionEventHandler<HTMLDivElement> | — |
| onTransitionRunCapture | TransitionEventHandler<HTMLDivElement> | — |
| onTransitionStart | TransitionEventHandler<HTMLDivElement> | — |
| onTransitionStartCapture | TransitionEventHandler<HTMLDivElement> | — |
| onWheel | WheelEventHandler<HTMLDivElement> | — |
| onWheelCapture | WheelEventHandler<HTMLDivElement> | — |
| Name | Type | Default |
|---|---|---|
| className | ClassNameOrFunction<ToggleButtonRenderProps> | 'react-aria-ToggleButton' |
The CSS className (opens in new tab) for the element. A function may be provided to compute the class based on component state. | ||
| style | StyleOrFunction<ToggleButtonRenderProps> | — |
The inline style (opens in new tab) for the element. A function may be provided to compute the style based on component state. | ||
ToggleButtonGroup
| Name | Type | Default |
|---|---|---|
| children | ChildrenOrFunction<ToggleButtonGroupRenderProps> | — |
The children of the component. A function may be provided to alter the children based on component state. | ||
| disallowEmptySelection | boolean | — |
Whether the collection allows empty selection. | ||
| fullWidth | boolean | — |
Set to true to span all available space of parent. | ||
| isDisabled | boolean | — |
Whether all items are disabled. | ||
| noSeparators | boolean | false |
Sets dividers between the ToggleButtons. | ||
| orientation | Orientation | horizontal |
The orientation of the the toggle button group. | ||
| selectionMode | "multiple" | "single" | single |
Whether single or multiple selection is enabled. | ||
| size | "lg" | "md" | "sm" | md |
Size applied to all | ||
| Name | Type | Default |
|---|---|---|
| aria-describedby | string | — |
Identifies the element (or elements) that describes the object. | ||
| aria-details | string | — |
Identifies the element (or elements) that provide a detailed, extended description for the object. | ||
| aria-label | string | — |
Defines a string value that labels the current element. | ||
| aria-labelledby | string | — |
Identifies the element (or elements) that labels the current element. | ||
| Name | Type | Default |
|---|---|---|
| dir | string | — |
| hidden | boolean | — |
| inert | boolean | — |
| lang | string | — |
| render | DOMRenderFunction<"div", ToggleButtonGroupRenderProps> | — |
Overrides the default DOM element with a custom render function. This allows rendering existing components with built-in styles and behaviors such as router links, animation libraries, and pre-styled components. Requirements:
| ||
| slot | string | null | — |
A slot name for the component. Slots allow the component to receive props from a parent component. An explicit | ||
| suppressHydrationWarning | boolean | — |
A React-only flag that suppresses the warning React normally logs when an element's server-rendered content doesn't match the client render during hydration. See React docs (opens in new tab). | ||
| translate | "no" | "yes" | — |
| Name | Type | Default |
|---|---|---|
| onAnimationEnd | AnimationEventHandler<HTMLDivElement> | — |
| onAnimationEndCapture | AnimationEventHandler<HTMLDivElement> | — |
| onAnimationIteration | AnimationEventHandler<HTMLDivElement> | — |
| onAnimationIterationCapture | AnimationEventHandler<HTMLDivElement> | — |
| onAnimationStart | AnimationEventHandler<HTMLDivElement> | — |
| onAnimationStartCapture | AnimationEventHandler<HTMLDivElement> | — |
| onAuxClick | MouseEventHandler<HTMLDivElement> | — |
| onAuxClickCapture | MouseEventHandler<HTMLDivElement> | — |
| onClickCapture | MouseEventHandler<HTMLDivElement> | — |
| onContextMenu | MouseEventHandler<HTMLDivElement> | — |
| onContextMenuCapture | MouseEventHandler<HTMLDivElement> | — |
| onDoubleClick | MouseEventHandler<HTMLDivElement> | — |
| onDoubleClickCapture | MouseEventHandler<HTMLDivElement> | — |
| onGotPointerCapture | PointerEventHandler<HTMLDivElement> | — |
| onGotPointerCaptureCapture | PointerEventHandler<HTMLDivElement> | — |
| onLostPointerCapture | PointerEventHandler<HTMLDivElement> | — |
| onLostPointerCaptureCapture | PointerEventHandler<HTMLDivElement> | — |
| onMouseDown | MouseEventHandler<HTMLDivElement> | — |
| onMouseDownCapture | MouseEventHandler<HTMLDivElement> | — |
| onMouseEnter | MouseEventHandler<HTMLDivElement> | — |
| onMouseLeave | MouseEventHandler<HTMLDivElement> | — |
| onMouseMove | MouseEventHandler<HTMLDivElement> | — |
| onMouseMoveCapture | MouseEventHandler<HTMLDivElement> | — |
| onMouseOut | MouseEventHandler<HTMLDivElement> | — |
| onMouseOutCapture | MouseEventHandler<HTMLDivElement> | — |
| onMouseOver | MouseEventHandler<HTMLDivElement> | — |
| onMouseOverCapture | MouseEventHandler<HTMLDivElement> | — |
| onMouseUp | MouseEventHandler<HTMLDivElement> | — |
| onMouseUpCapture | MouseEventHandler<HTMLDivElement> | — |
| onPointerCancel | PointerEventHandler<HTMLDivElement> | — |
| onPointerCancelCapture | PointerEventHandler<HTMLDivElement> | — |
| onPointerDown | PointerEventHandler<HTMLDivElement> | — |
| onPointerDownCapture | PointerEventHandler<HTMLDivElement> | — |
| onPointerEnter | PointerEventHandler<HTMLDivElement> | — |
| onPointerLeave | PointerEventHandler<HTMLDivElement> | — |
| onPointerMove | PointerEventHandler<HTMLDivElement> | — |
| onPointerMoveCapture | PointerEventHandler<HTMLDivElement> | — |
| onPointerOut | PointerEventHandler<HTMLDivElement> | — |
| onPointerOutCapture | PointerEventHandler<HTMLDivElement> | — |
| onPointerOver | PointerEventHandler<HTMLDivElement> | — |
| onPointerOverCapture | PointerEventHandler<HTMLDivElement> | — |
| onPointerUp | PointerEventHandler<HTMLDivElement> | — |
| onPointerUpCapture | PointerEventHandler<HTMLDivElement> | — |
| onScroll | UIEventHandler<HTMLDivElement> | — |
| onScrollCapture | UIEventHandler<HTMLDivElement> | — |
| onSelectionChange | ((keys: Set<Key>) => void) | — |
Handler that is called when the selection changes. | ||
| onTouchCancel | TouchEventHandler<HTMLDivElement> | — |
| onTouchCancelCapture | TouchEventHandler<HTMLDivElement> | — |
| onTouchEnd | TouchEventHandler<HTMLDivElement> | — |
| onTouchEndCapture | TouchEventHandler<HTMLDivElement> | — |
| onTouchMove | TouchEventHandler<HTMLDivElement> | — |
| onTouchMoveCapture | TouchEventHandler<HTMLDivElement> | — |
| onTouchStart | TouchEventHandler<HTMLDivElement> | — |
| onTouchStartCapture | TouchEventHandler<HTMLDivElement> | — |
| onTransitionCancel | TransitionEventHandler<HTMLDivElement> | — |
| onTransitionCancelCapture | TransitionEventHandler<HTMLDivElement> | — |
| onTransitionEnd | TransitionEventHandler<HTMLDivElement> | — |
| onTransitionEndCapture | TransitionEventHandler<HTMLDivElement> | — |
| onTransitionRun | TransitionEventHandler<HTMLDivElement> | — |
| onTransitionRunCapture | TransitionEventHandler<HTMLDivElement> | — |
| onTransitionStart | TransitionEventHandler<HTMLDivElement> | — |
| onTransitionStartCapture | TransitionEventHandler<HTMLDivElement> | — |
| onWheel | WheelEventHandler<HTMLDivElement> | — |
| onWheelCapture | WheelEventHandler<HTMLDivElement> | — |
| Name | Type | Default |
|---|---|---|
| defaultSelectedKeys | Iterable<Key> | — |
The initial selected keys in the collection (uncontrolled). | ||
| selectedKeys | Iterable<Key> | — |
The currently selected keys in the collection (controlled). | ||
| Name | Type | Default |
|---|---|---|
| className | ClassNameOrFunction<ToggleButtonGroupRenderProps> | 'react-aria-ToggleButtonGroup' |
The CSS className (opens in new tab) for the element. A function may be provided to compute the class based on component state. | ||
| style | StyleOrFunction<ToggleButtonGroupRenderProps> | — |
The inline style (opens in new tab) for the element. A function may be provided to compute the style based on component state. | ||