Updated
Inline Confirm
Customize
Color
Timeout4.0s
Medium
Start
Radius12px
Installation
npx shadcn@latest add https://uibrik.com/r/inline-confirm.jsonInstall the packages
npm install @tabler/icons-react motion react-use-measureAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/inline-confirm/inline-confirm.tsx"use client"; import { IconTrash } from "@tabler/icons-react"; import { AnimatePresence, motion } from "motion/react"; import { useEffect, useRef, useState, type CSSProperties, type MouseEvent } from "react"; import useMeasure from "react-use-measure"; import { cn } from "@/lib/utils"; // Widths ride a critically damped spring: it keeps its velocity when the prompt // is reversed mid-way, so backing out never stutters, and it settles without // overshoot. const MORPH = { type: "spring", duration: 0.45, bounce: 0 } as const; const EASE_OUT: [number, number, number, number] = [0.23, 1, 0.32, 1]; const SIZES = { sm: { height: 32, padX: 11, font: 13, icon: 14 }, md: { height: 40, padX: 14, font: 14, icon: 16 }, lg: { height: 48, padX: 17, font: 15, icon: 18 }, } as const; // A second click inside this window is the tail of a double-click, not a // decision, so it can't confirm. const ARM_DELAY = 350;
Adds the files to
components/uibrik/inline-confirm and installs @tabler/icons-react, motion and react-use-measure. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/inline-confirm.Usage
import { InlineConfirm } from "@/components/uibrik/inline-confirm/inline-confirm";<InlineConfirm label="Delete" confirmLabel="Confirm" cancelLabel="Cancel" color="#dc2626" timeout={4} size="md" icon cancelSide="start" radius={12} onConfirm={() => {}}/>Where to use Inline Confirm
Delete in lists and tables
Splitting into Cancel and Confirm in its own footprint avoids a modal for small deletions.
Pairs with Hold to Confirm
Removing members or files
Nothing around the button moves, so the confirm appears exactly under the user's pointer.
Pairs with Invite Members
Compact cards
Card footers with no room for a dialog still get a safe confirmation step.
Props
InlineConfirm- label
- Type string
- "Delete"
- Button text.
- confirmLabel
- Type string
- "Confirm"
- cancelLabel
- Type string
- "Cancel"
- color
- Type string
- "#dc2626"
- Colour of the destructive action.
- timeout
- Type number
- 4
- How long an unanswered prompt waits before backing out. 0 waits forever.
- size
- Type "sm" | "md" | "lg"
- "md"
- Height, padding and text size.
- icon
- Type boolean
- true
- Show the trash icon beside the label.
- cancelSide
- Type "start" | "end"
- "start"
- Which side Cancel grows out on.
- radius
- Type number
- 12
- Corner radius.
- onConfirm
- Type () => void
- –
- Called when the action is confirmed.
- className
- Type string
- –
- Classes for the wrapper.