Actions Core Stable

Toggle

Two-state button carrying aria-pressed, for a single on/off option like a formatting mark or a filter

Preview

Installation

pnpm add fancy-ui-svelte
import { Toggle } from 'fancy-ui-svelte'

Usage

svelte
<script lang="ts">
  import { Toggle } from 'fancy-ui-svelte';
</script>

<Toggle />

Examples

Basic Usage

A single icon-only toggle with a bound pressed state.

Sizes

The three available sizes, sm/md/lg.

Variants

Ghost vs. outline, resting and pressed.

Text Formatting

A bold/italic/underline row with a live preview.

Props

PropTypeDefaultDescription
pressed booleanfalseWhether the toggle is currently pressed (active); bindable
onPressedChange (pressed: boolean) => void-Called with the new pressed state whenever the toggle is activated
disabled booleanfalseDisables the toggle; blocks both the state change and the callback
size "sm" | "md" | "lg""md"Visual size of the control
variant "ghost" | "outline""ghost""ghost" has no resting border, "outline" keeps one at rest
label string-Accessible name — required when children is icon-only
class string-Additional CSS classes
ref HTMLButtonElement | nullnullBindable element reference

Slots

SlotDescription
childrenToggle content, typically a single glyph or a short label