Pace UI

Form Switch

Forms 1

About

A toggle switch field wired to TanStack Form with a label, on/off state, and inline validation errors.

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

Code

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

Usage.tsx

"use client";

import { FormSwitch } from "@/components/ui/form-switch";
import { useForm } from "@tanstack/react-form";

export default function FormSwitchDemo() {
  const form = useForm({
    defaultValues: {
      notifications: true,
    },
  });

  return (
    <form
      onSubmit={(e) => {
        e.preventDefault();
        form.handleSubmit();
      }}
      className="flex w-full max-w-sm flex-col gap-6"
    >
      <FormSwitch
        form={form}
        name="notifications"
        label="Enable notifications"
      />
    </form>
  );
}

Dependencies

More by Pace UI

View all
  • Dot Loader

    Dot Loader

    960
  • Flip Reveal

    Flip Reveal

    669
  • Dot Flow

    Dot Flow

    267
  • Draw Line Text

    Draw Line Text

    119
  • Liquid Glass

    Liquid Glass

    62
  • Liquid Cursor

    Liquid Cursor

    51
  • Layered Stack

    Layered Stack

    46
  • Calendar Heatmap Chart

    Calendar Heatmap Chart

    10

More in Forms

View all
  • Premium Auth

    Premium Auth

    593
  • Contact Form

    Contact Form

    28
  • Form

    Form

    4
  • Login 1

    Login 1

    70
  • Book A Demo 1

    Book A Demo 1

    94
  • Contact Card

    Contact Card

    1.1K
  • HeroUI Field Error

    HeroUI Field Error

    13
  • Form [react-aria-components]

    Form [react-aria-components]

    19

Explore more

Part of Pace UI — browse the full library on 21st.dev.