Loading Button
A button with a spoked loading spinner whose width flows to fit each state label.
Interactive preview · desktop · dark
Installation
Installation is available on the Startup and Business plans. Your personal install command appears here once you have access.
Usage
Import it, pass your props, and make it part of your product.
example.tsx
'use client';
import { useState } from 'react';import { ButtonWithLoader, type ButtonStateType,} from '@/components/component-kit/items/button-with-loader';
export function Example() { const [state, setState] = useState<ButtonStateType>('idle');
function deploy() { if (state === 'success') { setState('idle'); return; } setState('loading'); // Replace the timeout with your async work. setTimeout(() => setState('success'), 1200); }
return ( <ButtonWithLoader state={state} labels={{ idle: 'Deploy project', loading: 'Deploying', success: 'Deployed' }} onClick={deploy} /> );}Props
| Prop | Type | Default | Description |
|---|---|---|---|
size | "sm" | "default" | "lg" | default | Pill height: 28, 32 or 36px. |
state | "idle" | "loading" | "success" | "error" | idle | Current action state. Set it to "loading" from your click handler. |
labels | ButtonStateLabels | — | Override the label for each state. |