DocsComponentsTemplatesThemesGitHub

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.json

Guidelines

  • Mount <Toaster /> once; call toast({ title, description, tone, action }) anywhere.
  • Auto-dismiss after 5s; danger toasts stay until dismissed.
  • Confirm what happened in past tense: "Project created".

Props

PropTypeRequired
idnumberNo
titleReact.ReactNodeYes
descriptionReact.ReactNodeNo
tone'success' | 'danger' | 'warning' | 'neutral' | 'info'No
iconstringNo
action{ label: string; onClick: () => void }No
onDismiss() => voidNo
classNamestringNo

Edit this example on GitHub