---
title: "Toggle"
type: component
version: "2.2.2"
doc_version: "2.7.3"
status: stable
date: 2026-07-05
library: Frutjam
stack: tailwind_css
compatibility: universal
framework_agnostic: true
runtime_requirement: none
description: "Tailwind CSS Toggle using native HTML inputs. Accessible on/off switch with custom colors, sizes, and label support for settings and preference forms."
url: https://frutjam.com/pl/components/toggle
---

# Toggle Component

Toggle components are binary switches that allow users to turn features or settings on and off. Built with native HTML checkbox inputs and enhanced with Tailwind CSS animations, toggles provide an intuitive way to control boolean states. The Frutjam toggle system supports multiple colors, sizes, and disabled states—perfect for settings panels, feature flags, and preference controls.

Tylko CSS, nie wymaga JavaScript. Dostępny w WCAG AA i niezależny od frameworka — współpracuje z Django, HTMX, Laravel, React i dowolnym stosem.

| Klasa            | Typ     | Opis                                   |
| ---------------- | ------- | -------------------------------------- |
| toggle           | Opierać | Animowane wejście włącznika/wyłącznika |
| toggle-xs        | Rozmiar | Bardzo mały                            |
| toggle-sm        | Rozmiar | Mały                                   |
| toggle-md        | Rozmiar | Średni (domyślny)                      |
| toggle-lg        | Rozmiar | Duży                                   |
| toggle-xl        | Rozmiar | Bardzo duży                            |
| toggle-primary   | Kolor   | Podstawowy kolor motywu                |
| toggle-secondary | Kolor   | Kolor motywu drugorzędnego             |
| toggle-accent    | Kolor   | Kolor motywu akcentującego             |
| toggle-neutral   | Kolor   | Neutralny kolor motywu                 |
| toggle-info      | Kolor   | Kolor semantyczny informacji           |
| toggle-success   | Kolor   | Sukces semantyczny kolor               |
| toggle-warning   | Kolor   | Ostrzeżenie kolor semantyczny          |
| toggle-error     | Kolor   | Błąd koloru semantycznego              |

## Podstawowe użycie

## Przełącz rozmiary

```html
<input type="checkbox" class="toggle toggle-xs">
<input type="checkbox" class="toggle toggle-sm">
<input type="checkbox" class="toggle toggle-md">
<input type="checkbox" class="toggle toggle-lg">
<input type="checkbox" class="toggle toggle-xl">
```

## Przełącz kolory

```html
<input type="checkbox" class="toggle" checked>
<input type="checkbox" class="toggle toggle-primary" checked>
<input type="checkbox" class="toggle toggle-secondary" checked>
<input type="checkbox" class="toggle toggle-accent" checked>
<input type="checkbox" class="toggle toggle-info" checked>
<input type="checkbox" class="toggle toggle-success" checked>
<input type="checkbox" class="toggle toggle-warning" checked>
<input type="checkbox" class="toggle toggle-error" checked>
```

## Wyłączony przełącznik

```html
<input type="checkbox" class="toggle" disabled>
<input type="checkbox" class="toggle" disabled checked>
```

## Przełącz za pomocą etykiety

```html
<label class="flex items-center gap-2">
  <input type="checkbox" class="toggle toggle-primary" checked>
  <span>Enable notifications</span>
</label>

<label class="flex items-center gap-2">
  <input type="checkbox" class="toggle toggle-success" checked>
  <span>Dark mode</span>
</label>

<label class="flex items-center gap-2">
  <input type="checkbox" class="toggle toggle-warning">
  <span>Analytics</span>
</label>
```

## Przełącz stany

```html
<div class="flex gap-4 items-center">
  <div>
    <p class="text-sm font-medium mb-2">Off</p>
    <input type="checkbox" class="toggle toggle-primary">
  </div>
  <div>
    <p class="text-sm font-medium mb-2">On</p>
    <input type="checkbox" class="toggle toggle-primary" checked>
  </div>
  <div>
    <p class="text-sm font-medium mb-2">Disabled</p>
    <input type="checkbox" class="toggle toggle-primary" disabled>
  </div>
</div>
```

