Skip to content

Toggle

Toggle Primitive Text Component

Demo


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

Installation

Terminal window
npx @react-native-reusables/cli@latest add toggle

Usage

import * as React from 'react';
import { View } from 'react-native';
import { Toggle, ToggleIcon } from '~/components/ui/toggle';
import { Bold } from '~/lib/icons/Bold';
function Example() {
const [pressed, setPressed] = React.useState(false);
return (
<View className='flex-1 justify-center items-center p-6 gap-12'>
<Toggle
pressed={pressed}
onPressedChange={setPressed}
aria-label='Toggle bold'
variant='outline'
>
<ToggleIcon icon={Bold} size={18} />
</Toggle>
</View>
);
}

Props

Toggle

Extends Pressable props

PropTypeNote
pressedboolean
onPressedChange(val: boolean) => void
asChildboolean(optional)
disabledboolean(optional)
variant’default’ | ‘outline’(optional)
size’default’ | ‘sm’ | ‘lg’(optional)

ToggleIcon

Extends LucideIcon props

PropTypeNote
iconLucideIcon