AI button
A sparkle button that shows a spinner while the model works.
Installation
pnpm add @heyramzi/uiUsage
import { AiButton, type AiStatus } from "@heyramzi/ui/ai/ai-button";<AiButton {status} label="Draft reply" processingLabel="Drafting..." onclick={draft} />
<AiButton iconOnly {status} onclick={draft} />Keyboard and accessibility
| Key | Does |
|---|---|
| Space Enter | Runs the action. |
- The icon button is named by label, then by processingLabel while it works.
- While it works it reports disabled and ignores presses, and focus stays on it.
- Nothing is read out when the work finishes. Change the label, as the demo does, or announce it yourself.
API reference
status"idle" | "processing" | "done"- Default
"idle" labelstring- Default
"Generate" processingLabelstring- Default
"Processing..." variantButtonProps["variant"]- Default
"outline" sizeButtonProps["size"]- Default
"sm" disabledboolean- Default
false onclick(e: MouseEvent) => voidclassstringiconOnlyboolean- Default
false
| Prop | Type | Default |
|---|---|---|
status | "idle" | "processing" | "done" | "idle" |
label | string | "Generate" |
processingLabel | string | "Processing..." |
variant | ButtonProps["variant"] | "outline" |
size | ButtonProps["size"] | "sm" |
disabled | boolean | false |
onclick | (e: MouseEvent) => void | |
class | string | |
iconOnly | boolean | false |