confirm/01-basic-confirm
A single button that swaps in place: Delete account, then Confirm, then Undo. No title or description.
Loading interactive preview
'use client';
import { useState } from 'react';
import { Icon } from 'ui-lab-components/icon';
import { Button } from 'ui-lab-components/button';
import { Flex } from 'ui-lab-components/flex';
type Step = 'idle' | 'confirming' | 'deleted';
const steps: Record<Step, { label: string; icon: React.ReactNode; next: Step }> = {
idle: { label: 'Delete account', icon: <Icon id="trash" size="1em" />, next: 'confirming' },
confirming: { label: 'Confirm', icon: <Icon id="check" size="1em" />, next: 'deleted' },
deleted: { label: 'Undo', icon: <Icon id="restart" size="1em" />, next: 'idle' },
};
export default function Example() {
const [step, setStep] = useState<Step>('idle');
const { label, icon, next } = steps[step];
return (
<Flex justify-center w={160}>
<Button icon={{ left: icon }} onPress={() => setStep(next)}>
{label}
</Button>
</Flex>
);
}