micka_design

Switch

Forms 90

About

A fluid animated switch with draggable thumb, smooth pill morphing on hover/press, and accessible keyboard support.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Switch to your project and fits it to your theme.

Code

How Switch is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import { useState } from "react";
import { Switch } from "../components/ui/switch";

export default function SwitchGroupDemo() {
  const [states, setStates] = useState({ notifications: true, emails: false, sounds: true, analytics: false });
  const toggle = (key: keyof typeof states) => setStates(s => ({ ...s, [key]: !s[key] }));
  return (
    <div className="flex items-center justify-center min-h-screen bg-background">
      <div className="transform scale-150 flex flex-col">
        <Switch label="Notifications" checked={states.notifications} onToggle={() => toggle("notifications")} />
        <Switch label="Emails" checked={states.emails} onToggle={() => toggle("emails")} />
        <Switch label="Sounds" checked={states.sounds} onToggle={() => toggle("sounds")} />
        <Switch label="Analytics" checked={states.analytics} onToggle={() => toggle("analytics")} />
      </div>
    </div>
  );
}

Dependencies

More by micka_design

View all
  • Select

    Select

    86
  • Checkbox Group

    Checkbox Group

    82
  • Segmented Tabs

    Segmented Tabs

    48
  • Table

    Table

    40
  • Accordion

    Accordion

    38
  • Tabs Subtle

    Tabs Subtle

    25
  • Slider

    Slider

    24
  • Button

    Button

    19

More in Forms

View all
  • Form

    Form

    17
  • Premium Auth

    Premium Auth

    568
  • Login 1

    Login 1

    62
  • Book A Demo 1

    Book A Demo 1

    90
  • Contact Card

    Contact Card

    1.1K
  • Book A Demo 3

    Book A Demo 3

    101
  • Card Studio

    Card Studio

    46
  • Login Card

    Login Card

    33