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.
Install @radix-ui/react-toggle
Copy/paste the following code for web to ~/components/primitives/toggle/toggle.web.tsx
Copy/paste the following code for native to ~/components/primitives/toggle/toggle.tsx
Copy/paste the following code for types to ~/components/primitives/toggle/types.ts
Copy/paste the following code for exporting to ~/components/primitives/toggle/index.ts
Copy/paste the following code for native to ~/components/primitives/toggle/index.tsx
Copy/paste the following code for types to ~/components/primitives/toggle/types.ts
Usage
Props
Root
Extends Pressable
props
Prop | Type | Note |
---|---|---|
pressed | boolean | |
onPressedChange | (val: boolean) => void | |
asChild | boolean | (optional) |
disabled | boolean | (optional) |