vijayksingh

Switch

Component

About

A pill-shaped toggle control for turning a setting on or off that takes effect immediately, with regular and small sizes.

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 * as React from "react";
import Switch from "@/components/ui/switch";

export default function SwitchDemo() {
  const [on, setOn] = React.useState(true);
  return (
    <div className="flex items-center gap-28">
      <Switch aria-label="Regular" checked={on} onCheckedChange={setOn} />
      <Switch aria-label="Small" size="small" defaultChecked />
      <Switch aria-label="Disabled" disabled defaultChecked />
    </div>
  );
}

Dependencies

More by vijayksingh

View all
  • Weather Widget

    Weather Widget

    74
  • Meter

    Meter

    10
  • Skeleton Loader

    Skeleton Loader

    9
  • Textarea

    Textarea

    2
  • Well

    Well

    1
  • Soft Hardware Spinner

    Soft Hardware Spinner

    1
  • Settings List

    Settings List

  • Perfect Preview

    Perfect Preview