Base Pure CSS

Switch

The on/off toggle over a native checkbox with the switch role; label, description, three sizes and Livewire binding — riding the form’s save, or live as it flips.

Real scenarios

The component as it is used in a product — not a specimen grid.

How the shop hears about orders

The switches bind with wire:model, so they ride along with the save — until then nothing is committed, and the count below shows what the shop has actually saved.

0 of 3 channels saved as on.

The storefront’s vacation mode

A bare size="lg" switch in its own row, named through aria-label; wire:model.live posts the flip as it happens and the panel answers — no save button anywhere.

Pause the storefront Guests see the away note; orders wait in the panel.

The storefront is open

Orders come through and checkout is live.

The access column in the members table

Bare size="sm" switches in their own column — each named through aria-label so it says itself to a screen reader, while the badge beside it restates the state in colour and words.

  • مریم صادقی Product designer No access
  • سامان دهقان Fulfillment lead No access
  • هدی کریمی Support agent No access

0 of 3 members can enter the panel.

Important props

Important props
Prop Type Default What it does
label / description string null The label and description beside the toggle; without them the bare switch renders — name it with aria-label.
size string md Toggle size: sm · md · lg — sm for table rows, lg for a page’s main toggle.
wire:model bool — With wire:model the value rides the next action (the save button); wire:model.live posts it the moment it flips.
disabled / checked bool false Native attributes land on the input itself; disabled and checked are the ones that matter for locked settings.

Snippet

<x-nx::switch label="احراز هویت دو مرحله‌ای" description="با پیامک"
    wire:model="state.mfa" />

<x-nx::switch size="lg" wire:model.live="state.vacation"
    aria-label="توقف ویترین" />

<x-nx::switch label="درگاه پرداخت" checked disabled />