ToggleButton API

API documentation for ToggleButton component

ToggleButton#

Props#

Defines valid properties in ToggleButton component.

nametypedefaultdescription
refRef<unknown>
null
The reference to the component instance.
pIfboolean
true
Whether the component should be rendered.
styleCSSProperties | ((instance?: ToggleButtonInstance) => CSSProperties)
null
The style to apply to the component.
classNamestring | ((instance?: ToggleButtonInstance) => string)
null
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
null
The component type to render.
asChildboolean
false
Whether the component should be rendered as a child component.
ptSafeRecord<ToggleButtonPassThrough>
null
The pass-through props to pass to the component
ptOptionsPassThroughOptions
null
The pass-through options to pass to the component
unstyledboolean
null
Whether the component should be rendered without classes.
dtunknown
null
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
null
The styles to use for the component.
childrenReactNode | ((instance: ToggleButtonInstance) => ReactNode)
null
The children to render.
valueunknown
null
Value of the ToggleButton.
size"small" | "large" | "normal"
null
Defines the size of the ToggleButton.
disabledboolean
false
When present, it specifies that the element should be disabled.
invalidboolean
false
When present, it specifies that the component should have invalid state style.
onPressedChange(event: ToggleButtonChangeEvent) => void
null
Callback fired when the ToggleButton's pressed state changes.
pressedboolean
null
When present, it specifies that the ToggleButton should be pressed.
defaultPressedboolean
null
The default pressed value when not controlled by `pressed` and `onPressedChange` .
[key: string]any
null
pt-{optionName}-*-
null
Pass through attributes for customizing component. For more info, see Pass Through tab.

State#

Defines valid state in ToggleButton component.

nametypedefaultdescription
pressedboolean
null
The pressed state of the useToggleButton.

Exposes#

Defines the methods and properties exposed by ToggleButton component.

nametypedefaultdescription
groupToggleButtonGroupInstance
null
The group instance of the ToggleButton.
stateuseToggleButtonState
null
The state of the useToggleButton.
onChange(event: useToggleButtonChangeEvent) => void
null
Callback fired when the useToggleButton's pressed state changes.

Events#

Event fired when the ToggleButton's checked state changes.

nametypedescription
valueunknownValue of the ToggleButton.
originalEventChangeEventThe original event that triggered the change.
pressedbooleanThe pressed state of the ToggleButton.

Interfaces#

Defines passthrough(pt) options of ToggleButton component.

nametypedefaultdescription
rootToggleButtonPassThroughType<HTMLAttributes<HTMLDivElement>>
null
Used to pass attributes to the root's DOM element.
indicatorToggleButtonPassThroughType<HTMLAttributes<HTMLSpanElement>>
null
Used to pass attributes to the indicator's DOM element.

Types#

Instance of ToggleButton component.

values
ComponentInstance<ToggleButtonProps, ToggleButtonState, ToggleButtonExposes>

ToggleButtonIndicator#

Props#

Defines valid properties in ToggleButtonIndicator component.

nametypedefaultdescription
refRef<unknown>
null
The reference to the component instance.
pIfboolean
true
Whether the component should be rendered.
styleCSSProperties | ((instance?: ToggleButtonIndicatorInstance) => CSSProperties)
null
The style to apply to the component.
classNamestring | ((instance?: ToggleButtonIndicatorInstance) => string)
null
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
null
The component type to render.
asChildboolean
false
Whether the component should be rendered as a child component.
ptSafeRecord<ToggleButtonIndicatorPassThrough>
null
The pass-through props to pass to the component
ptOptionsPassThroughOptions
null
The pass-through options to pass to the component
unstyledboolean
null
Whether the component should be rendered without classes.
dtunknown
null
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
null
The styles to use for the component.
childrenReactNode | ((instance: ToggleButtonIndicatorInstance) => ReactNode)
null
The children to render.
[key: string]any
null
pt-{optionName}-*-
null
Pass through attributes for customizing component. For more info, see Pass Through tab.

Exposes#

Defines the methods and properties exposed by ToggleButtonIndicator component.

nametypedefaultdescription
togglebuttonToggleButtonInstance
null
The ToggleButton component instance.

Interfaces#

Defines passthrough(pt) options of ToggleButtonIndicator component.

nametypedefaultdescription
rootToggleButtonIndicatorPassThroughType<HTMLAttributes<HTMLDivElement>>
null
Used to pass attributes to the root's DOM element.

Types#

Instance of ToggleButtonIndicator component.

values
ComponentInstance<ToggleButtonIndicatorProps, ToggleButtonIndicatorState, ToggleButtonIndicatorExposes>

ToggleButtonGroup#

Props#

Defines valid properties in ToggleButtonGroup component.

nametypedefaultdescription
refRef<unknown>
null
The reference to the component instance.
pIfboolean
true
Whether the component should be rendered.
styleCSSProperties | ((instance?: ToggleButtonGroupInstance) => CSSProperties)
null
The style to apply to the component.
classNamestring | ((instance?: ToggleButtonGroupInstance) => string)
null
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
null
The component type to render.
asChildboolean
false
Whether the component should be rendered as a child component.
ptSafeRecord<ToggleButtonGroupPassThrough>
null
The pass-through props to pass to the component
ptOptionsPassThroughOptions
null
The pass-through options to pass to the component
unstyledboolean
null
Whether the component should be rendered without classes.
dtunknown
null
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
null
The styles to use for the component.
childrenReactNode | ((instance: ToggleButtonGroupInstance) => ReactNode)
null
The children to render.
valueunknown
null
Value of the ToggleButton group.
defaultValueunknown
null
The default value of the ToggleButton group.
size"small" | "large" | "normal"
null
Defines the size of the ToggleButton components.
multipleboolean
false
When present, it specifies that the ToggleButton group allows multiple selections.
allowEmptyboolean
true
When present, it specifies that the ToggleButton group allows empty selection.
disabledboolean
false
When present, it specifies that the ToggleButton group should be disabled.
invalidboolean
false
When present, it specifies that the ToggleButton group is invalid.
onValueChange(event: ToggleButtonGroupValueChangeEvent) => void
null
Callback function that is called when the ToggleButton group value changes.
[key: string]any
null
pt-{optionName}-*-
null
Pass through attributes for customizing component. For more info, see Pass Through tab.

State#

Defines valid state in ToggleButtonGroup component.

nametypedefaultdescription
valueunknown
null
Value of the ToggleButton group.

Exposes#

Defines the methods and properties exposed by ToggleButtonGroup component.

nametypedefaultdescription
stateToggleButtonGroupState
null
The state of the ToggleButton group.
updateChange(event: ToggleButtonGroupUpdateChangeEvent) => void
null
Updates the value of the ToggleButton group.
isPressed(value: unknown, toggleButtonValue: unknown) => boolean
null
Checks if a toggle button is pressed. Returns true if the toggle button is pressed, false if not pressed, or undefined if the value is undefined.

Events#

Event fired when the ToggleButton group's value changes.

nametypedescription
valueunknownThe value of the ToggleButton group.

Used to update the ToggleButton group value.

nametypedescription
valueunknownValue of the ToggleButton.
originalEventChangeEventThe original event that triggered the change.
pressedbooleanThe pressed state of the ToggleButton.

Interfaces#

Defines passthrough(pt) options of ToggleButton component.

nametypedefaultdescription
rootToggleButtonGroupPassThroughType<HTMLAttributes<HTMLDivElement>>
null
Used to pass attributes to the root's DOM element.

Types#

Instance of ToggleButtonGroup component.

values
ComponentInstance<ToggleButtonGroupProps, ToggleButtonGroupState, ToggleButtonGroupExposes>

useToggleButton#

Props#

Defines valid properties in useToggleButton.

nametypedefaultdescription
pressedboolean
null
When present, it specifies that the ToggleButton should be pressed.
defaultPressedboolean
null
The default pressed value when not controlled by `pressed` and `onPressedChange` .
onPressedChange(event: useToggleButtonChangeEvent) => void
null
Callback fired when the ToggleButton's pressed state changes.

State#

Defines valid state in useToggleButton.

nametypedefaultdescription
pressedboolean
null
The pressed state of the useToggleButton.

Exposes#

Defines the methods and properties exposed by useToggleButton.

nametypedefaultdescription
stateuseToggleButtonState
null
The state of the useToggleButton.
onChange(event: useToggleButtonChangeEvent) => void
null
Callback fired when the useToggleButton's pressed state changes.

Events#

Event fired when the ToggleButton's checked state changes.

nametypedescription
originalEventEThe original event that triggered the change.
pressedbooleanThe pressed state of the ToggleButton.

Types#

Instance of useToggleButton headless.

values
HeadlessInstance<useToggleButtonProps, useToggleButtonState, useToggleButtonExposes>