Async button with idle, loading, and success states.
npx shadcn@latest add @iconiq/flux-button"use client";
import { Check } from "lucide-react";
import { FluxButton } from "@/components/ui/flux-button";
export function FluxButtonPreview() {
return (
<div className="mx-auto max-w-2xl text-center">
<p className="flex flex-wrap items-center justify-center gap-x-2 gap-y-2 text-balance font-medium text-lg text-neutral-800 leading-snug tracking-tight sm:text-xl dark:text-neutral-100">
<span>When the form is ready,</span>
<span className="font-medium text-foreground">Default</span>
<span>Tap</span>
<span className="inline-flex translate-y-px align-middle">
<FluxButton
idleLabel="Submit"
loadingLabel="Submitting"
successIcon={<Check aria-hidden className="size-4" strokeWidth={2.5} />}
successLabel="Submitted"
onAction={async () => {
await new Promise((resolve) => setTimeout(resolve, 1500));
}}
type="button"
variant="default"
/>
</span>
<span>to finish.</span>
</p>
</div>
);
}idleLabelLabel shown before the action starts.
Type string
loadingLabelLabel shown with the built-in loader while onAction is in progress.
Type string
successLabelLabel shown after onAction resolves.
Type string
successIconOptional icon shown on success. Pass any node, such as a Lucide checkmark. Omit for text-only success.
Type React.ReactNode
onActionRuns when the button is pressed, drives loading and success states, then returns to idle after successHold.
Type () => void | Promise<void>
variantVisual style variant. Matches the b-button variant set.
Type "default" | "outline" | "secondary" | "ghost" | "destructive" | "link"·Default default
successHoldMilliseconds to hold the success state before returning to the idle label.
Type number·Default 1000
sizeHeight and horizontal padding preset. Matches b-button sizes.
Type "xs" | "sm" | "default" | "lg"·Default default
typeNative button type. Use submit inside forms; defaults to button so the control does not submit unless you opt in.
Type "button" | "submit"·Default button
disabledNative disabled state. Also blocks the action flow while true.
Type boolean·Default false
classNameOptional class names merged onto the root button element.
Type string
onClickNative click handler forwarded to the underlying button.
Type React.MouseEventHandler<HTMLButtonElement>
Install the exact registry entry shown on the right when you want the component file and its declared runtime dependencies together.
Dependencies: @base-ui/react/button, class-variance-authority, lucide-react, motion.
This page documents the Base UI install only. Flux Button builds on the Base UI button primitive.
The generated registry file is /r/flux-button.json.
Contact
Additionally, if you find any bug or issue, feel free to raise an issue.