Updated
Tactile Toggles
Notifications
Customize
Accent
Squish6px
Installation
npx shadcn@latest add https://uibrik.com/r/tactile-toggles.jsonInstall the packages
npm install motionAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/tactile-toggles/tactile-toggles.tsx"use client"; import { useId, useRef, useState, type ReactNode } from "react"; import { AnimatePresence, motion, useReducedMotion } from "motion/react"; import { cn } from "@/lib/utils"; // ─── Geometry ───────────────────────────────────────────────────────────────── const TRACK_W = 44; const TRACK_H = 26; const PAD = 2; const KNOB = TRACK_H - PAD * 2; // Pointer travel before a press counts as a drag rather than a tap. const DRAG_SLOP = 3; const SPRING = { type: "spring", stiffness: 520, damping: 34, mass: 0.7 } as const; const INSTANT = { duration: 0 } as const; // Off track: a tint of the text colour, so it reads in light and dark alike. const TRACK_OFF = "color-mix(in srgb, var(--foreground) 14%, transparent)"; export type ToggleItem = { id: string; label: string; description?: string; defaultChecked?: boolean;
Adds the files to
components/uibrik/tactile-toggles and installs motion. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/tactile-toggles.Usage
import { TactileToggles } from "@/components/uibrik/tactile-toggles/tactile-toggles";const items = [ { id: "push", label: "Push notifications", description: "Mentions and replies", defaultChecked: true }, { id: "digest", label: "Weekly digest", description: "A summary every Monday" }, // …2 more];<TactileToggles title="Notifications" accent="#22c55e" wash squish={6} items={items} onChange={(id, checked) => {}}/>Where to use Tactile Toggles
Notification settings
A tint sweeping across the row as switches turn on makes each change visible.
Pairs with Settings Page
Feature flags
Pausing the rows a switch overrides shows dependencies between settings.
App preferences
A list of tactile switches suits mobile-style settings screens.
Props
TactileToggles- title
- Type string
- "Notifications"
- Heading above the list.
- accent
- Type string
- "#22c55e"
- Switch colour when on, and the wash colour.
- wash
- Type boolean
- true
- Sweep a faint tint across the row when a switch turns on.
- squish
- Type number
- 6
- How far the knob stretches while pressed.
- items
- Type ToggleItem[]
- –
- Rows: { id, label, description?, defaultChecked?, overrides? }. A row with overrides pauses those rows while it's on.
- onChange
- Type (id: string, checked: boolean) => void
- –
- Called when a switch flips.
- className
- Type string
- –
- Classes for the outer shell.