russellbloxwich

Switch

Forms

About

A toggle switch control for turning a single setting on or off, built on Radix UI's switch primitive with a compact and small size variant.

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";
import { Label } from "@/components/ui/label";

export default function SwitchSmallSizeDemo() {
  const id = React.useId();
  const [logging, setLogging] = React.useState(true);

  return (
    <div className="flex items-center gap-2 bg-background p-6 text-foreground">
      <Switch
        id={`${id}-logging`}
        sizeVariant="sm"
        checked={logging}
        onCheckedChange={setLogging}
      />
      <Label htmlFor={`${id}-logging`}>Save request logs</Label>
    </div>
  );
}

Dependencies

More by russellbloxwich

View all
  • Sensitive Input

    Sensitive Input

    5
  • Chart

    Chart

    4
  • Code Block

    Code Block

    4
  • Layer Card

    Layer Card

    3
  • Meter

    Meter

    1
  • Field

    Field

    1
  • Direction Provider

    Direction Provider

    1
  • Toast Notifications

    Toast Notifications

    1

More in Forms

View all
  • Login 1

    Login 1

    64
  • Premium Auth

    Premium Auth

    571
  • Contact Card

    Contact Card

    1.1K
  • Form

    Form

    18
  • Book A Demo 1

    Book A Demo 1

    91
  • Authentication Card

    Authentication Card

    52
  • Card Studio

    Card Studio

    47
  • Login Card

    Login Card

    35