Select UI framework
Get Started
Radix UI
AlertApp Store ButtonAspect RatioBadgeBannerBreadcrumbButton GroupButtonCheckboxCommand MenuCompactButtonDialogDrawerDropdown MenuEmptyFancy ButtonFile UploadHintInput OTPInputItemKbdLabelLinkButtonLoaderPopoverProgress BarProgress CircleRadio GroupRatingSelectSeparatorSkeletonSliderSocial ButtonSwitchTagTextareaToggle GroupToggleTooltip
Component toggle-demo not found in registry.
Usage
import { Bold } from "lucide-react"
import * as Toggle from "@/registry/radix-ui/ui/toggle"
export function ToggleExample() {
const [bold, setBold] = React.useState(false)
return (
<Toggle.Root
pressed={bold}
onPressedChange={setBold}
variant="primary"
appearance="outline"
>
<Toggle.Icon>
<Bold className="size-4" />
</Toggle.Icon>
Bold
</Toggle.Root>
)
}Examples
Basic Toggle
Component toggle-demo not found in registry.
Ghost Appearance
Component toggle-ghost not found in registry.
Different Sizes
Component toggle-sizes not found in registry.
Props
Toggle.Root
This component is based on the Radix UI Toggle primitive and supports all of its props.
Prop
Type
Default
appearance
outlineghostoutline
size
xssmmdlgmd
pressed
boolean-
defaultPressed
boolean-
onPressedChange
(pressed: boolean) => void-
disabled
boolean-
asChild
booleanfalse
className
string-
children
ReactNode-