Updated
Progress Submit
NewCustomize
Duration0.45s
Radius12px
Installation
npx shadcn@latest add https://uibrik.com/r/progress-submit.jsonInstall the packages
npm install @tabler/icons-react motionAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/progress-submit/progress-submit.tsx"use client"; import { useEffect, useLayoutEffect, useRef, useState, type ButtonHTMLAttributes, type MouseEvent, type ReactNode, } from "react"; import { AnimatePresence, animate, motion, useMotionValue, useReducedMotion, useTransform } from "motion/react"; import { IconCircleArrowRightFilled, IconCircleCheckFilled } from "@tabler/icons-react"; import { cn } from "@/lib/utils"; // Progress submit. A submit button that fills as its form gets filled in: two of // four fields done is half a fill. The label sits on two layers, a quiet one on // the track and an inverted one on the fill, both clipped at the fill's edge, so a // letter can be half filled while the edge passes through it. // // When the fill reaches the end the button turns on: its arrow rises in and one // soft sheen crosses the fill. Submitting swaps the arrow for a spinner, then a // check, and a new label eases in while the button re-centres to fit it. //
Adds the files to
components/uibrik/progress-submit and installs @tabler/icons-react and motion. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/progress-submit.Usage
import { ProgressSubmit } from "@/components/uibrik/progress-submit/progress-submit";<ProgressSubmit children="Create account" duration={0.45} radius={12} status="idle" icon={<IconCircleArrowRightFilled />} doneIcon={<IconCircleCheckFilled />} onIncomplete={() => {}} // progress={0}/>Where to use Progress Submit
Sign-up and checkout forms
The button shows how much is left, so nobody wonders why it won't click.
Settings with required fields
Clicking early nudges the button and can focus the first empty field.
Pairs with Unsaved Changes
Multi-step onboarding
Pass the share of steps done and the same fill tracks the whole flow.
Props
ProgressSubmit- children
- Type string
- "Create account"
- The label.
- duration
- Type number
- 0.45
- How long the fill takes to reach a new value.
- radius
- Type number
- 12
- Corner radius.
- progress
- Type number
- –
- How much of the form is done, 0 to 1. The button turns on at 1.
- onIncomplete
- Type () => void
- –
- Called when the button is clicked before the form is complete, e.g. to focus the first empty field.
- status
- Type "idle" | "loading" | "done"
- "idle"
- While submitting: a spinner, then a check. Change the label alongside it and it eases in.
- icon
- Type ReactNode
- <IconCircleArrowRightFilled />
- Rises in after the label once the form is complete. Pass null for none.
- doneIcon
- Type ReactNode
- <IconCircleCheckFilled />
- Shown after the label when status is done.
- ...button props
- Type ButtonHTMLAttributes
- –
- onClick, type (default submit), disabled, className and the rest pass through.