Submit Button
A button that holds its width through idle, loading, success and error, with a spinner, a drawn tick and a shake.
$
View as Markdownnpx shadcn@latest add https://sundaeui.dev/r/submit-button.jsonOverview
Width is locked to the widest label so nothing around it jumps. Loading swaps the label for a spinner; success draws a tick; error shakes once and shows a short reason, then returns to idle.
It is driven by a status prop, so it works with any async handler or form library.
When to use
- Forms, saves, payments, any async action.
When not to use
- Instant actions with no network round trip.
Installation
$
pnpm dlx shadcn@latest add https://sundaeui.dev/r/submit-button.json$
npx shadcn@latest add https://sundaeui.dev/r/submit-button.json$
yarn dlx shadcn@latest add https://sundaeui.dev/r/submit-button.json$
bunx --bun shadcn@latest add https://sundaeui.dev/r/submit-button.jsonWorks in any React project. Files are written to components/sundae/. Read the source in the stage’s Code view.
- No dependencies beyond React 18 or later.
- Copy submit-button.tsx and submit-button.css into components/sundae/.
- The CSS file is imported by the component, so no extra configuration is needed.
- Import the component and use it as shown below.
Usage
import { SubmitButton } from '@/components/sundae/submit-button'
<SubmitButton />Props
| Prop | Type | Default |
|---|---|---|
status*Current state. | 'idle' | 'loading' | 'success' | 'error' | — |
labelsLabel per state. | Partial<Record<Status, string>> | — |
onClickClick handler. | () => void | — |
fillSurface: dark or light. | 'dark' | 'light' | 'dark' |
Accessibility
- aria-busy while loading and aria-disabled so focus is not lost; state text is announced politely.
- Reduced motion removes the movement and keeps every state change.
Customization
- Colours are CSS custom properties on .sd-sbm; override them in your own stylesheet.
- fill="light" switches the built-in light palette.
FAQ
- Is Submit Button free?
- Yes. Submit Button is free for personal and commercial projects, with full source on this page.
- How do I install Submit Button?
- Run npx shadcn@latest add https://sundaeui.dev/r/submit-button.json. The files are written to components/sundae/. It has no dependencies beyond React 18 or later.
- Does Submit Button support keyboard and screen readers?
- aria-busy while loading and aria-disabled so focus is not lost; state text is announced politely. Reduced motion removes the movement and keeps every state change.
- Does Submit Button respect reduced motion?
- Reduced motion removes the movement and keeps every state change.
More like this
All components →Download Button
Components · RefinedHold to Confirm
Components · RefinedFollow Button
Components · RefinedBookmark Button
Components · RefinedSplit Button
Components · RefinedInline Alert
Components · Refined