Skip to content

Square Switch

Square toggle: a hairline rectangle with a square knob that snaps across with the emphasized ease, filling ink when on; mono ON/OFF state label; role=switch.

mono-clean/effect/square-switch
Open ↗

Source

"use client";

import { useState } from "react";
import { cn } from "@/lib/utils";

export interface SquareSwitchProps {
  label?: string;
  defaultChecked?: boolean;
  onCheckedChange?: (checked: boolean) => void;
  className?: string;
}

/** Square toggle: a hairline rectangle with a square knob that snaps across with the emphasized ease, filling ink when on; mono ON/OFF state label; role=switch. */
export function SquareSwitch({ label = "Show project index", defaultChecked = true, onCheckedChange, className }: SquareSwitchProps) {
  const [on, setOn] = useState(defaultChecked);
  return (
    <label className={cn("flex cursor-pointer items-center justify-between gap-6 border-b border-da-border py-4", className)}>
      <span>{label}</span>
      <span className="flex items-center gap-3">
        <span aria-hidden className="w-6 font-da-mono text-[11px] tracking-da-label text-da-muted-fg uppercase">
          {on ? "On" : "Off"}
        </span>
        <button
          type="button"
          role="switch"
          aria-checked={on}
          onClick={() => {
            setOn(!on);
            onCheckedChange?.(!on);
          }}
          className={cn(
            "da-focus relative h-5 w-10 border border-da-border-strong transition-colors duration-(--da-duration)",
            on ? "bg-da-fg" : "bg-transparent",
          )}
        >
          <span
            className={cn(
              "absolute top-0.5 left-0.5 size-3.5 transition-[translate,background-color] duration-(--da-duration-slow) ease-da-emphasized motion-reduce:transition-none",
              on ? "translate-x-5 bg-da-bg" : "bg-da-fg",
            )}
          />
        </button>
      </span>
    </label>
  );
}

export default SquareSwitch;

modules/mono-clean/effect/square-switch/index.tsx

Props

PropTypeDefaultDescription
labelstring—Label.
defaultCheckedboolean—Default Checked.
onCheckedChange(checked: boolean) => void—Callback.
classNamestring—Extra classes on the root.

Other micro interaction variants in Mono Clean

Micro interaction in other art directions

Animated

Click Burst

Micro-interaction wrapper that fires a burst of outlined square shards in DA colors from the click point (or from the center on Enter/Space), spinning outward in stepped motion.

BrutalistMicro interaction
Animated

Cursor Follower

Region where a tilted, outlined sticker label trails the mouse pointer with a springy lag and pops in/out on enter/leave. Mouse only; add cursor-none on the region to replace the cursor.

BrutalistMicro interaction
Animated

Shake Feedback

Error micro-interaction wrapper: shakes its content horizontally in hard steps and flashes a thick danger outline each time shakeKey changes (wrong password, invalid code). Children keep their state.

BrutalistMicro interaction
Animated

Stack Hover

Micro-interaction wrapper: colored slabs hidden behind a card or button fan out diagonally on hover and keyboard focus, in stepped motion, like a stack of printed sheets. Pure CSS.

BrutalistMicro interaction
Animated

Glare Card

Glass card where a soft specular glare and a luminous primary rim follow the mouse pointer (CSS variables, masked border), like light sliding over real glass.

GlassMicro interaction
Animated

Gradient Border

Highlight wrapper with a rotating conic-gradient border (primary → accent → pink) and optional soft glow around a frosted inner surface. Pure CSS via a registered @property angle.

GlassMicro interaction
Animated

Liquid Button

Frosted pill button that fills with a wavy primary→accent liquid rising from the bottom on hover or keyboard focus while the label turns white. Pure CSS.

GlassMicro interaction
Animated

Tilt Card

Frosted card that tilts in 3D toward the pointer on a spring while a specular glare slides across the glass; eases back flat on leave. Motion values only, no re-render per move.

GlassMicro interaction
Animated

Border Beam

Card wrapper with a short primary-to-accent light beam travelling around its rounded 1px border (conic gradient + animated @property angle); always on or only on hover/focus.

MinimalMicro interaction
Animated

Magnetic Button

Wrapper that pulls its child toward the mouse pointer on hover with a spring (inner content moves a little more for depth) and snaps back on leave.

MinimalMicro interaction
Animated

Ripple Press

Subtle press ripple expanding from the pointer inside any rounded child (button, card), in the current text color or primary tone, fading out quickly without blocking clicks.

MinimalMicro interaction
Animated

Spotlight Card

Card micro-interaction: a soft indigo radial light follows the pointer inside the card while the 1px border brightens under the cursor. CSS variables only, no React re-render per move.

MinimalMicro interaction
Animated

Copy Feedback

Copyable mono field (API key, IBAN, invoice link): click copies, the icon cross-fades to a green check and a “Copied” tooltip pops for 1.6s; announced to screen readers.

Neo CorporateMicro interaction
Animated

Press Ripple

Button with a restrained material-style ripple: a soft circle expands from the press point and fades, plus a 1px press-down; disabled with reduced motion.

Neo CorporateMicro interaction
Animated

Spotlight Border

Card whose 1px border lights up in primary around the pointer (a radial highlight follows the cursor along the edge) with a faint inner glow; plain bordered card on touch.

Neo CorporateMicro interaction
Animated

Toggle Save

Settings row with an auto-saving switch: the knob slides, an inline status shows a spinner “Saving…” then a green “Saved” check that fades after 2s (aria-live).

Neo CorporateMicro interaction
Animated

Breathe Button

Calm primary CTA that slowly “breathes”: a soft sage halo expands and fades around the pill every few seconds; pauses on hover and with reduced motion. Pure CSS.

Organic SoftMicro interaction
Animated

Leaf Like

Appreciation button: pressing fills the leaf with sage, bumps it with a soft overshoot and releases three small leaves that float up and fade; counter updates.

Organic SoftMicro interaction
Animated

Sprout Progress

Progress bar with a plant riding the fill: a rounded sage track whose leading edge carries a sprout that grows leaves at 33% and 66% and blooms at 100%.

Organic SoftMicro interaction
Animated

Water Ripple

Surface that answers a tap like still water: three concentric sage rings spread from the pointer and fade. Wrap any card or panel.

Organic SoftMicro interaction
Animated

Check Burst

Satisfying task checkbox: the round box fills mint with a bouncy check and a ring of pastel dots bursts outward when ticked; the label strikes through.

Soft FlatMicro interaction
Animated

Heart Like

Like button: the heart pops with a springy scale, fills red and throws a ring of tiny hearts; the count ticks and the pill tints.

Soft FlatMicro interaction
Animated

Hover Lift

Card wrapper that lifts, tilts a couple of degrees and grows a soft wide shadow on hover or keyboard focus-within, with a springy ease.

Soft FlatMicro interaction
Animated

Squish Button

Chunky “gummy” pill button with a flat darker bottom lip that squishes down (scales wider/shorter, lip disappears) when pressed and springs back. CSS only.

Soft FlatMicro interaction