Toast
Transient confirmation with optional action (Undo) and dismiss. Use via Toaster + toast().
Code
import * as React from 'react';
import { Toast } from '@fruit-labs/design';
export default function Demo() {
return (
<div
style={{
display: 'flex',
flexDirection: 'column',
gap: 10,
maxWidth: 380,
}}
>
<Toast
title="Project created"
description="Mobile onboarding is ready."
action={{
label: 'View',
onClick() {},
}}
{...{
onDismiss() {},
}}
/>
<Toast
tone="neutral"
title="Moved to trash"
description="1 file"
action={{
label: 'Undo',
onClick() {},
}}
/>
<Toast
tone="danger"
title="Couldn’t save"
description="Check your connection."
{...{
onDismiss() {},
}}
/>
</div>
);
}Install
From npm:
npm install @fruit-labs/design
import { Toast } from '@fruit-labs/design';Or copy the TypeScript source into your project:
npx shadcn@latest add https://design.fruitlabs.online/r/toast.jsonGuidelines
- Mount
<Toaster />once; calltoast({ title, description, tone, action })anywhere. - Auto-dismiss after 5s; danger toasts stay until dismissed.
- Confirm what happened in past tense: "Project created".
Props
| Prop | Type | Required |
|---|---|---|
id | number | No |
title | React.ReactNode | Yes |
description | React.ReactNode | No |
tone | 'success' | 'danger' | 'warning' | 'neutral' | 'info' | No |
icon | string | No |
action | { label: string; onClick: () => void } | No |
onDismiss | () => void | No |
className | string | No |