Component

Toggle Switch Input

Toggle switch components for boolean settings and preferences

  • Component
  • Tailwind
  • MIT

Preview

Live component

Interactive preview
Open preview
9:41 100%
devsnips.site/library/tailwind/components/input/toggle-switch/
fluid · no fixed width 100%
No dependencies Production-ready

Install

Add to your project

terminal
npx devsnips add Tailwind/Components/Input/toggle-switch
registry path: Tailwind/Components/Input/toggle-switch

Source

Implementation

code.html
<!-- Toggle Switch - Default -->
<div class="space-y-4">
  <div class="flex items-center justify-between">
    <span class="text-sm font-medium text-gray-700">Enable notifications</span>
    <button class="relative w-12 h-6 bg-gray-200 rounded-full transition-colors peer-checked:bg-blue-600">
      <input type="checkbox" class="sr-only peer" />
      <span class="absolute top-0.5 left-0.5 w-5 h-5 bg-white rounded-full shadow-sm transition-transform peer-checked:translate-x-6"></span>
    </button>
  </div>
  <div class="flex items-center justify-between">
    <span class="text-sm font-medium text-gray-700">Dark mode</span>
    <button class="relative w-12 h-6 bg-blue-600 rounded-full transition-colors">
      <input type="checkbox" checked class="sr-only" />
      <span class="absolute top-0.5 left-0.5 w-5 h-5 bg-white rounded-full shadow-sm transition-transform translate-x-6"></span>
    </button>
  </div>
  <div class="flex items-center justify-between">
    <span class="text-sm font-medium text-gray-700">Disabled</span>
    <button class="relative w-12 h-6 bg-gray-200 rounded-full opacity-50 cursor-not-allowed">
      <input type="checkbox" class="sr-only" disabled />
      <span class="absolute top-0.5 left-0.5 w-5 h-5 bg-white rounded-full shadow-sm"></span>
    </button>
  </div>
</div>

<!-- Toggle Switch - Pill -->
<div class="mt-6 p-4 bg-gray-50 rounded-xl">
  <div class="flex items-center justify-between mb-4">
    <div>
      <p class="text-sm font-medium text-gray-900">Push notifications</p>
      <p class="text-xs text-gray-500">Receive alerts on your device</p>
    </div>
    <button class="relative w-14 h-8 bg-gray-200 rounded-full transition-colors">
      <input type="checkbox" class="sr-only" />
      <span class="absolute top-1 left-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform translate-x-6"></span>
    </button>
  </div>
  <div class="flex items-center justify-between">
    <div>
      <p class="text-sm font-medium text-gray-900">Email digest</p>
      <p class="text-xs text-gray-500">Weekly summary to your inbox</p>
    </div>
    <button class="relative w-14 h-8 bg-green-500 rounded-full transition-colors">
      <input type="checkbox" checked class="sr-only" />
      <span class="absolute top-1 left-1 w-6 h-6 bg-white rounded-full shadow-md transition-transform translate-x-6"></span>
    </button>
  </div>
</div>

<!-- Toggle Switch - Colored -->
<div class="mt-6 space-y-3">
  <div class="flex items-center justify-between">
    <span class="text-sm font-medium text-gray-700">Success state</span>
    <button class="relative w-12 h-6 bg-green-500 rounded-full transition-colors">
      <input type="checkbox" checked class="sr-only" />
      <span class="absolute top-0.5 left-0.5 w-5 h-5 bg-white rounded-full shadow transition-transform translate-x-6"></span>
    </button>
  </div>
  <div class="flex items-center justify-between">
    <span class="text-sm font-medium text-gray-700">Warning state</span>
    <button class="relative w-12 h-6 bg-amber-500 rounded-full transition-colors">
      <input type="checkbox" checked class="sr-only" />
      <span class="absolute top-0.5 left-0.5 w-5 h-5 bg-white rounded-full shadow transition-transform translate-x-6"></span>
    </button>
  </div>
</div>
66 lines UTF-8 · LF · Spaces: 2
DevSnips AI ready Claude · Cursor · Windsurf

Agent skill & Model Context Protocol

Pass this component straight into your AI workflow. DevSnips exposes each resource as a structured, addressable registry entry, so your agent installs the real files instead of approximating them.

devsnips://components/input/toggle-switch
Prompt instruction
I want to use this DevSnips resource in production:

Page:
https://devsnips.site/library/tailwind/components/input/toggle-switch/

Install: npx devsnips add
Tailwind/Components/Input/toggle-switch

This is the Toggle Switch Input — Toggle switch components for boolean settings and preferences

Use this DevSnips resource as the starting point for my project.
Adapt it to my project's stack and conventions, fix any issues,
and make it production-ready while preserving its intended design
and behavior.

Paste into ChatGPT, Claude or your agent — it already carries the page URL and the exact install path.

Resource URI
devsnips://components/input/toggle-switch