Efniv0.1

Components

Toggle

A binary press-in-out control. For an on/off setting attached to a label, prefer Switch. For multiple exclusive options, prefer Toggle group.

When to usefor a single icon-shaped state that flips on and off — pin, star, mute, lock — usually inside a toolbar.

Import

import { Toggle } from "@ravnhq/efni/toggle"

Variants

<Toggle aria-label="Pin"><Icon icon={Pin} /></Toggle>
<Toggle variant="outline" aria-label="Star"><Icon icon={Star} /></Toggle>

Sizes

<Toggle size="sm" | "default" | "lg" />

With label

<Toggle variant="outline">
  <Icon icon={Bell} />
  Notifications
</Toggle>

<Toggle variant="outline" defaultPressed>
  <Icon icon={Volume2} />
  Sound on
</Toggle>

Accessibility

KeyAction
Enter / SpaceToggle the pressed state.
TabMove focus to and from the toggle.
  • Always give icon-only toggles an aria-label.
  • Base UI uses `pressed` / `defaultPressed` (not Radix's `on`); the DOM attr is aria-pressed.

Props

PropTypeDefaultDescription
variant"default" | "outline""default"Visual style.
size"default" | "sm" | "lg""default"Height and padding.
pressedboolean—Whether the toggle button is currently pressed. This is the controlled counterpart of defaultPressed.
defaultPressedbooleanfalseWhether the toggle button is currently pressed. This is the uncontrolled counterpart of pressed.
onPressedChange((pressed: boolean, eventDetails: Toggle.ChangeEventDetails) => void)—Callback fired when the pressed state is changed.
…propsTogglePrimitive.Props—Everything Toggle passes to the element it renders.