Skip to content

Toggle Primitive

A button with a true or false state, which can be activated or deactivated by toggling.

Installation

Install the component via your command line.

Terminal window
npx expo install @rn-primitives/toggle

Usage

import * as React from 'react';
import { Text } from 'react-native';
import * as TogglePrimitive from '@rn-primitives/toggle';
function Example() {
const [isActive, setIsActive] = React.useState(false);
return (
<TogglePrimitive.Root pressed={isActive} onPressedChange={setIsActive}>
<Text>Bold</Text>
</TogglePrimitive.Root>
);
}

Props

Root

Extends Pressable props

PropTypeNote
pressedboolean
onPressedChange(val: boolean) => void
asChildboolean(optional)
disabledboolean(optional)