Skip to content

Morph Button

An action label contracts into a circular loader and resolves to a checkmark.

LIVE PREVIEWInteract with the component
Just React. No extra dependencies.

Copy the component and its CSS module into your project.

CSS Modules

Usage

Matches your current playground settings.

jsx
import MorphButton from "./MorphButton";
export default function Example() {
return (
<MorphButton
children={"Save changes"}
status={"idle"}
loadingLabel={"Saving changes"}
successLabel={"Changes saved"}
color={"#b8c1d4"}
textColor={"#252b37"}
width={190}
disabled={false}
/>
);
}

Using Morph Button

Run your action from onClick and set status to loading while it is pending. Change it to success when the action completes, or idle to show the label again.

Loading disables further activation and exposes aria-busy. Supply meaningful loadingLabel and successLabel values; the component does not start requests or set its own completion timer.

Props

NameTypeRequiredDefaultDescription
childrenReactNodeNoundefinedIdle action label.
status"idle" | "loading" | "success"No"idle"Caller-controlled visual state.
loadingLabelstringNo"Loading"Accessible loading-state label.
successLabelstringNo"Completed"Accessible success-state label.
colorstringNo"#b8c1d4"Button surface colour.
textColorstringNo"#252b37"Label and icon colour.
widthnumberNo190Resting button width in pixels.
disabledbooleanNofalseDisable the button independently of status.
onClickfunctionNoundefinedNative click handler.
type"button" | "submit" | "reset"No"button"Native button type.
...restButtonHTMLAttributesNoundefinedAdditional native attributes such as aria-label and form.
classNamestringNo""Additional classes on the root element.
styleCSSPropertiesNoundefinedInline styles for sizing, typography and appearance.

Related components

Alternating shutters close into a solid button face on hover or focus.

A raised rubber-stamp button leaves a fading outline when pressed.

A sculpted keycap compresses into its base with a satisfying press.

A clipped corner floods the button with colour as its arrow turns.