Playground GitHub npm

Toggle

Two-state pressable button (default/outline).

ui form

Preview

Installation

npx slintcn@latest add toggle

Usage

import { Toggle, ToggleVariant } from "slintcn/components/toggle.slint";

Toggle { text: "Bold"; pressed <=> bold; }

Properties

text in string

Label rendered inside.

pressed in-out bool

Two-way pressed state.

variant in ToggleVariant

Visual style — `default` or `outline`.

disabled in bool

When true, dims and stops responding.

toggled callback (bool)

Fired with the new `pressed` value.

API

ToggleVariantdefaultoutline
Accessibility
focusableyes
keyboardEnterSpace

Dependencies

theme only

Installed automatically as transitive dependencies of slintcn add toggle.