Your next page is taking shape...

Opening Your Next Page…

Loading the guide and preparing its examples for you to explore. The page will appear here automatically when it’s ready, so you can keep this view open without refreshing.

Made for Preact. Built to be yours.

Actions & Selection

Toggle

Toggle controls a binary pressed/unpressed state with modern Radix-style variants and sizes. Make the next action easy to recognize. Use visual emphasis deliberately and distinguish an action from a persistent selection or a navigation link. Import it from @/components/kamod-ui/toggle.

Source · Design reference · API reference · Theming · Styles


Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Installation

Import Toggle from @/components/kamod-ui/toggle.

Install PackagesTerminal
pnpm add @kamod-ch/ui

Copy an example with @kamod-ch/ui or the matching @kamod-ch/ui/… subpath. The code block switches between those two installs. Connect The Global Theme CSS and Tailwind Source Detection before your first render.

Usage

Use variant, size, and controlled state props to match toolbar and settings use-cases.

Import SetupTypeScript
import { Toggle } from "@kamod-ch/ui";

Choose a complete composition from the examples below; required child components and props vary by pattern.

Component Examples & Variants

Explore Toggle in Different Contexts, from the starting pattern to the compositions below. Begin with Basic Toggle, then compare the examples that match your content, state and layout. These are working patterns to adapt, not a list of interchangeable variant values: check the API Reference before using a prop or combining behaviors. Look at the surrounding labels, supporting text and spacing as well as the component itself.

Read the Result and Its Implementation Together. Use each showcase’s Code view to inspect imports and composition, or its Prompt view to prepare a setup or adaptation brief. Try the narrow preview and local theme controls before connecting real data, and use Reset to return an example to its initial state. Keep layout changes in class utilities where appropriate; follow the Component Styles Guide for hierarchy and the Theming Guide for shared surfaces and colors. The Accessibility Notes explain what to preserve when making those changes.

Basic Toggle

Represent a Persistent on/off Choice. Use Toggle for a boolean pressed state, such as an active formatting option. An initial pressed value establishes the starting presentation, while subsequent changes should represent a persistent choice rather than a one-time command.

Keep its accessible name stable enough to understand the state and connect the pressed value to the actual feature; use an ordinary Button for actions without a retained selection.

src/components/ToggleExample.tsx8 lines
import { Toggle } from "@kamod-ch/ui";
import { Bold } from "lucide-preact";

export const Example = () => (
  <Toggle defaultPressed aria-label="Toggle bold">
    <Bold class="size-4" />
  </Toggle>
);

Toolbar Actions

Keep Formatting Choices Independently Meaningful. Arrange related toggles in a formatting toolbar when each button represents an on/off option. If the choices need shared exclusive or multiple selection behavior, compare Toggle Group before assembling separate state handlers.

Give each icon a clear accessible name and keep pressed states synchronized with the edited content rather than only the last pointer interaction.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Variants and Sizes

Match Visual Weight to the Toolbar. Choose the outline treatment when a toggle needs a more explicit boundary and an icon size when its symbol is sufficient visually. Give icon-only options accessible names that explain the setting they enable or disable.

Preserve a clear pressed state and visible keyboard focus in every combination, and avoid making the active treatment indistinguishable from a hover effect.

Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width
API reference

Props and Data

Configure Toggle using the contracts below. Read the documented options alongside the Source Definitions to understand which values your application supplies and which details the component owns. Start with a prop or helper, then follow its type link to inspect the declaration without leaving the page.

Props, slots and variants for this component.

API reference
Your API, from source

Type cards are extracted from this checkout’s TypeScript source at build time. Props inherited through HTMLAttributes, Omit or variant helpers remain references in those declarations; their fields are not flattened here. Match the reference to your installed version, and check a package’s exports before writing an import type. A type exported by a source file is not necessarily re-exported by @kamod-ch/ui.

Component Props

Read each option with its owning component. The
marker identifies required fields verified in that declaration. A ? means a field can be omitted; it does not promise a fallback value. Existing documented defaults remain alongside the descriptions. For callbacks, check the argument and return types before connecting your own state or services.
@kamod-ch/ui/toggle5.3 KB min · 1.7 KB gzipSignals: none

Toggle

ToggleProps

Toggle documented props
Prop / typeDescription
children
ComponentChild[] | ComponentChildToggleProps

Configure children for Toggle. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
class
stringToggleProps

Configure class for Toggle. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
defaultPressed
booleanToggleProps

Configure defaultPressed for Toggle. Compare its accepted type with the Usage Guidance before supplying a value.

Default
false
disabled
boolean | SignalLike<boolean | undefined>ToggleProps

Configure disabled for Toggle. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
name
string | SignalLike<string | undefined>ToggleProps

Configure name for Toggle. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
onClick
MouseEventHandler<HTMLButtonElement>ToggleProps

Configure onClick for Toggle. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
onPressedChange
((next: boolean) => void)ToggleProps

Configure onPressedChange for Toggle. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
pressed
booleanToggleProps

Configure pressed for Toggle. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
required
booleanToggleProps

Configure required for Toggle. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
size
"sm" | "default" | "lg" | "icon"ToggleProps

Configure size for Toggle. Compare its accepted type with the Usage Guidance before supplying a value.

Default
"default"
value
string | number | SignalLike<string | number | undefined>ToggleProps

Configure value for Toggle. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
variant
"default" | "outline"ToggleProps

Configure variant for Toggle. Compare its accepted type with the Usage Guidance before supplying a value.

Default
"default"

Data Type Reference

Expand a card to inspect and copy the exact declaration. The code header identifies its repository file; follow imported or inherited types in the Implementation Source when you need the complete dependency chain. Required-field summaries cover fields declared directly in that type. Source-only helpers and inferred schema outputs describe the local implementation, not additional props you can pass to every component.

Toggle Props

6 declared fields
ToggleProps
Exported Source Declaration from Toggle.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of ToggleProps before adapting it.

Accessibility

Toggle renders a button with aria-pressed reflecting its state. Pressed state represents a persistent choice, not just the brief visual feedback of clicking a normal action button.

Take the Next Useful Step

You have the pieces. Put them into one real interaction, keep its state in one place, and check the result with the content your application will actually show.

Connect the Foundation

Return to Choose and Compose Components to connect this reference to a working screen. Keep global CSS in one entrypoint and import only the components that screen needs.

Build the Surrounding Screen

Find a neighboring interaction in the Component Library, or start with a complete Block. Replace sample content and destinations before refining the layout; a local class change can stay with the composition.

Make the Result Hold Up

Use shared theme roles for changes that belong everywhere. Then review the whole journey: keyboard focus, long labels, narrow screens and a clear way to recover when something fails.

Keep a link to the source and note your intentional changes. Your next edit should begin with a clear decision, not another search.