Updated
Consequence Button
NewCustomize
Primary
Duration0.35s
Delay90ms
Radius12px
Installation
npx shadcn@latest add https://uibrik.com/r/consequence-button.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/consequence-button/consequence-button.tsx"use client"; import { Children, useCallback, useEffect, useRef, useState, type ButtonHTMLAttributes, type MouseEvent, type ReactNode } from "react"; import { animate, useReducedMotion, type AnimationPlaybackControls } from "motion/react"; import { cn } from "@/lib/utils"; // Consequence button. Hover or keyboard focus widens the button to show what a // click will do, in quieter text after the label: "Deploy · main → Production". // You read the outcome before you commit. On touch, where there's no hover, the // first tap shows it and a second tap acts. // // The detail sits at its natural width inside a clipping slot, and only the slot's // width animates, so text never squeezes, wraps or scales on the way. Each piece // of the detail (icons, words) arrives a beat after the one before it, reading // left to right, and a click sends the icon up and out, with a fresh one rising // from below. export type ConsequenceButtonProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, "children"> & { /** The label. */ children?: ReactNode; /** What a click will do, shown on hover and focus. */ detail: ReactNode; /** Shown before the label. */ icon?: ReactNode;
Adds the files to
components/uibrik/consequence-button and installs motion. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/consequence-button.Usage
import { ConsequenceButton } from "@/components/uibrik/consequence-button/consequence-button";<ConsequenceButton children="Deploy" variant="primary" duration={0.35} delay={90} launch radius={12} icon={<IconCircleArrowUpFilled />} // detail={<…/>}/>Where to use Consequence Button
Deploys and releases
Show the branch and environment a click will ship to.
Moves and sends
Move to · Archive, Send · 3 recipients: the target is clear before the click.
Pairs with Split Button
Billing actions
Upgrade · $24 a month shows the cost right on the button.
Props
ConsequenceButton- children
- Type string
- "Deploy"
- The label.
- variant
- Type "primary" | "secondary"
- "primary"
- Solid, or a quiet tinted fill.
- duration
- Type number
- 0.35
- How long the button takes to widen.
- delay
- Type number
- 90
- How long the pointer rests before the detail shows.
- launch
- Type boolean
- true
- Send the icon up and out on click, with a fresh one rising from below.
- radius
- Type number
- 12
- Corner radius.
- detail
- Type ReactNode
- –
- What a click will do. Text and small icons, kept to one line.
- icon
- Type ReactNode
- –
- Shown before the label.
- ...button props
- Type ButtonHTMLAttributes
- –
- onClick, disabled, className and the rest pass through.