useToggleButton

Provides the behavior and accessibility implementation for a toggle button component. ToggleButtons allow users to toggle a selection on or off, for example switching between two states or modes.

Install#

yarn add @react-native-aria/button

Import#

import {useToggleButton} from '@react-native-aria/button'

API#

useToggleButton(
props: AriaToggleButtonProps<ElementType>,
state: ToggleState,
ref: RefObject<any>
): ButtonAria<HTMLAttributes<any>>

AriaToggleButtonProps#

Props for the toggle button.

ToggleState#

ButtonAria#

{
/** Props for the Touchable/Pressable element. */
buttonProps: PressableProps,
/** Whether the button is currently pressed. */
isPressed: boolean
}

ref#

  • Ref of Pressable/Touchable

Usage#

Last updated on by Nishan