Status & Feedback
Toast
Toast displays transient notifications with Sonner-inspired variants and placement. Explain what is happening, what changed and what someone can do next. Pair visual status with language that still makes sense without its color. Import it from @/components/kamod-ui/toast.
Source · API reference · Theming · Styles
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthInstallation
Import Toaster and useToast from @/components/kamod-ui/toast and mount Toaster once near your app root.
pnpm add @kamod-ch/uiCopy an example with @kamod-ch/ui or the matching @kamod-ch/ui/… subpath. The code block switches between those two installs. Connect The Global Theme CSS and Tailwind Source Detection before your first render.
Usage
Trigger toasts with useToast and choose variant, duration and optional actionLabel. Use Toaster position to control placement.
import { Toast } from "@kamod-ch/ui";Choose a complete composition from the examples below; required child components and props vary by pattern.
Component Examples & Variants
Explore Toast in Different Contexts, from the starting pattern to the compositions below. Begin with Basic Toast, then compare the examples that match your content, state and layout. These are working patterns to adapt, not a list of interchangeable variant values: check the API Reference before using a prop or combining behaviors. Look at the surrounding labels, supporting text and spacing as well as the component itself.
Read the Result and Its Implementation Together. Use each showcase’s Code view to inspect imports and composition, or its Prompt view to prepare a setup or adaptation brief. Try the narrow preview and local theme controls before connecting real data, and use Reset to return an example to its initial state. Keep layout changes in class utilities where appropriate; follow the Component Styles Guide for hierarchy and the Theming Guide for shared surfaces and colors. The Accessibility Notes explain what to preserve when making those changes.
Basic Toast
Make the Notification Specific to the Action. Trigger a toast with a concise title and an optional description when an action produces useful feedback. The title communicates the outcome, while the supporting line can clarify its scope without interrupting the current task.
Keep important results available in the page when users may miss a transient message, and mount the toaster at the appropriate shared application level.
import { Toaster, useToast } from "lucide-preact"
import { Button } from "@kamod-ch/ui";
export const Example = () => {
const { toast } = useToast();
return (
<>
<Button onClick={() => toast({ title: "Event has been created", description: "Your settings have been updated.", variant: "success", actionLabel: "Undo" })}>
Show toast
</Button>
<Toaster />
</>
);
};Toast Dismiss
Manage the Message Alongside Its Operation. Keep the toast identifier when the application needs to dismiss a message after a workflow change. Removing obsolete feedback can be as important as showing the initial result, particularly when the user retries or reverses an action.
Distinguish dismissing a message from cancelling the underlying work, and avoid clearing unrelated feedback during a local state change.
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthToast Types
Choose a Tone that Matches the Result. Choose default, success, info, warning or error presentation according to the message's meaning. The visual variant helps recognition, while the actual title and description must still explain the outcome and any necessary response.
Use the same meanings throughout the application and avoid presenting a recoverable warning as a completed success merely to soften its appearance.
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthToast Position
Keep Notifications Clear of Important Controls. Compare the supported Toaster positions with the surrounding interface before selecting a default. The notification should remain discoverable without covering an important action or competing with persistent navigation at the same edge.
Test short and long messages at narrow widths, and choose one consistent position unless different regions have a clear purpose that users can understand.
Interactive preview
Preact example Local preview theme · Responsive styles follow the preview widthFull widthProps and Data
Configure Toast using the contracts below. Read the documented options alongside the Source Definitions to understand which values your application supplies and which details the component owns. Start with a prop or helper, then follow its type link to inspect the declaration without leaving the page.
Props, slots and variants for this component.
Type cards are extracted from this checkout’s TypeScript source at build time. Props inherited through HTMLAttributes, Omit or variant helpers remain references in those declarations; their fields are not flattened here. Match the reference to your installed version, and check a package’s exports before writing an import type. A type exported by a source file is not necessarily re-exported by @kamod-ch/ui.
Component Props
? means a field can be omitted; it does not promise a fallback value. Existing documented defaults remain alongside the descriptions. For callbacks, check the argument and return types before connecting your own state or services.Toaster
ToasterProps
| Prop / type | Description |
|---|---|
position | Configure
|
Data Type Reference
Expand a card to inspect and copy the exact declaration. The code header identifies its repository file; follow imported or inherited types in the Implementation Source when you need the complete dependency chain. Required-field summaries cover fields declared directly in that type. Source-only helpers and inferred schema outputs describe the local implementation, not additional props you can pass to every component.
Toaster Props
1 declared fieldToasterPropsToaster.tsx. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of ToasterProps before adapting it.ToastItemData
8 declared fieldsToastItemDatatoast-store.ts. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of ToastItemData before adapting it.id, titleAccessibility
Build the Complete Interaction, Including the Parts Outside Toast. The notes below distinguish the current implementation from the labels, content and behavior your application supplies. Start with the Live Preview, check the Props and Data Reference, and test the finished composition with real content rather than assuming that an unchanged visual example covers every use case.
Built-in Behavior and Defaults
Toaster renders a Notifications region with polite live behavior. Individual messages can use status or alert semantics according to their urgency, and dismissal buttons have a name. Announcement behavior depends on when messages enter the live region.
Labels and Relationships
Write a short result and, when relevant, a next step. Include the affected object when several background actions can finish at once. A generic Done message is less helpful than Invoice saved.
Keyboard and Focus
Do not move focus into a toast merely because it appeared. Make any dismissal or action reachable without disrupting the current task. Keep important recovery information in the page after the transient message disappears.
States and Integration Details
Avoid duplicating the same result in several assertive regions. Review timeout behavior for longer content and actionable messages, and reserve urgent announcements for changes that actually warrant interruption.
Verify the Complete Interaction
Check Behavior as Well as Markup. Work through these scenarios in the application where the component will be used. Automated checks can help find structural problems; also review the reading experience with a screen reader, keyboard focus and the actual feedback from your application.
- Trigger success and failure while a screen reader is reading other content and compare interruptions.
- Reach any toast action with the keyboard and confirm dismissal leaves focus in a useful place.
- Let the toast expire and verify important errors or recovery actions remain available elsewhere.
Recheck the result after changing Theme Tokens, translations or class overrides. Include text enlargement, narrow layouts and reduced-motion settings where animation is present. Inspect the Component Source when a behavior differs from your expectation; a role or state attribute does not implement keyboard interaction by itself.
For background, read the WAI-ARIA Authoring Guidance and Keyboard Interface Guidance. These explain the patterns; verify browser and assistive-technology behavior for the implementation and audience you actually support.
You have the pieces. Put them into one real interaction, keep its state in one place, and check the result with the content your application will actually show.
Connect the Foundation
Return to Choose and Compose Components to connect this reference to a working screen. Keep global CSS in one entrypoint and import only the components that screen needs.
Build the Surrounding Screen
Find a neighboring interaction in the Component Library, or start with a complete Block. Replace sample content and destinations before refining the layout; a local class change can stay with the composition.
Make the Result Hold Up
Use shared theme roles for changes that belong everywhere. Then review the whole journey: keyboard focus, long labels, narrow screens and a clear way to recover when something fails.
Keep a link to the source and note your intentional changes. Your next edit should begin with a clear decision, not another search.