Skip to content
Ballpoint

Toggle

A button that stays on or off: pressing it shades it in with the pen, pressing it again pulls the shading out.

From shadcn/ui
Built on Base UI Toggle

Installation

pnpm dlx shadcn@latest add @ballpoint/toggle

Usage

tsx
import { Toggle } from "@/components/ui/toggle"

<Toggle aria-label="Toggle bold">
  <BoldIcon />
</Toggle>

Examples

Outline

Boxed at rest, with and without a label.

Sizes

Small, default and large.

Controlled

Keep the pressed state in React and read it back.

Not in your favourites.

API reference

variant
default "default"
"default" | "outline"

Boxed only when you point at it, or boxed all the time.

size
default "default"
"default" | "sm" | "lg"

Height and type size.

pressed / defaultPressed
default false
boolean

Pressed or not, controlled or not.

onPressedChange
(pressed: boolean) => void

Called as it is pressed.

seed
string | number

Pins the drawing.

Every other prop goes to Base UI's Toggle.

Pen settings

The drawing also takes draw, roughness, passes, radius, corners, weight and speed, as props or from the nearest InkProvider. What each one does.