Toast
Transient notification with auto-dismiss and variant support. Declarative or programmatic.
Overview
The Toast component is a core building block of the Byteion design system, providing a robust, accessibility-compliant interface for its specific UI capabilities.
Why this exists
Toasts communicate transient messages that do not require immediate action. They appear, auto-dismiss, and stack when multiple fire at once.
Mental model
A toast is a temporary notification. It appears in a corner, shows for 3-5 seconds, and fades. Users should not need to dismiss it.
When to use
When not to use
Basic example
The following example demonstrates standard usage, fully compliant with Byteion's token-first approach.
Toast Notifications
Toast notifications provide brief updates about an app process. Click any of the trigger buttons below to test how the interactive toasts appear and auto-dismiss in the viewport.
Accent Border Toast
Features a crisp white card background with a bold left accent border and matching colored icon. Click the triggers below to fire interactive accent toasts.
Compact Toast
Short message with icon and close button. Perfect for brief, non-intrusive feedback.
Action Toast
Includes an optional action button (e.g. Undo, Retry, Reconnect) for instant user follow-up.
Stacked Toasts
Multiple toasts stack vertically. Click multiple buttons in succession to see them stack smoothly in the corner.
import { Button, ToastProvider, useToast } from '@byteion/react/client';
// 1. Wrap your app once at the root:
export function App() {
return (
<ToastProvider placement="bottom-right">
<ToastDemo />
</ToastProvider>
);
}
// 2. Trigger toasts anywhere inside the tree:
function ToastDemo() {
const toast = useToast();
return (
<div className="flex flex-wrap gap-3 p-6">
<Button onClick={() => toast.show({ tone: 'success', title: 'Saved',
message: 'Your changes are live.', duration: 3000 })}>Success</Button>
<Button variant="outline" onClick={() => toast.show({ tone: 'info',
title: 'Heads up', message: 'A new version is available.' })}>Info</Button>
<Button variant="outline" tone="warning" onClick={() => toast.show({
tone: 'warning', title: 'API limit',
message: "You've used 86% of quota." })}>Warning</Button>
<Button tone="danger" onClick={() => toast.show({ tone: 'danger',
title: 'Failed to save', message: 'Network error — please retry.' })}>Danger</Button>
</div>
);
}
<!-- 1. Mount the container once at your root (App.vue) -->
<script setup lang="ts">
import { Button, ToastContainer, useToast } from '@byteion/vue';
const toast = useToast();
function showSuccess() {
toast.show({ tone: 'success', title: 'Saved',
message: 'Your changes are live.', duration: 3000 });
}
function showInfo() {
toast.show({ tone: 'info', title: 'Heads up',
message: 'A new version is available.' });
}
function showWarning() {
toast.show({ tone: 'warning', title: 'API limit',
message: "You've used 86% of quota." });
}
function showDanger() {
toast.show({ tone: 'danger', title: 'Failed to save',
message: 'Network error — please retry.' });
}
</script>
<template>
<!-- Mount once at the application root: -->
<ToastContainer placement="bottom-right" />
<!-- Trigger from anywhere in the tree: -->
<div class="flex flex-wrap gap-3 p-6">
<Button @click="showSuccess">Success</Button>
<Button variant="outline" @click="showInfo">Info</Button>
<Button variant="outline" tone="warning" @click="showWarning">Warning</Button>
<Button tone="danger" @click="showDanger">Danger</Button>
</div>
</template>
Variants
Each variant communicates a different meaning. Choose based on priority, not aesthetics.
Single default variant.
Sizes
Size should match the importance and context of the component.
- md — md size.
States
This component reacts seamlessly to the following interaction and data states:
- visible — Rendered and interactive.
- hidden — Not rendered in the DOM.
- default — Resting appearance before interaction.
- hover — Pointer is over the element — visual feedback via color or shadow.
- focus — Keyboard or tab focus — shows ring indicator for accessibility.
- active — Currently selected or in use.
- disabled — Non-interactive — grayed out, cursor not-allowed.
Anatomy
Usage guidelines
- Auto-dismiss after 3-5 seconds.
- Keep messages under 10 words.
- Provide an action only when reversal is possible (Undo).
Do and Don't
Do
- Auto-dismiss.
- Keep messages short.
- Provide Undo when possible.
Don't
- Do not stack more than 3 toasts.
- Do not require dismissal.
- Do not use for critical errors.
- Do not play sound.
Accessibility
Toasts use aria-live="polite" so screen readers announce them. They do not steal focus.
Role:status (default) or alert (for errors)
ARIA Attributes
aria-liverole
Keyboard Navigation
- Escape
- Tab
Customization
Position and colors follow toast tokens.
Compose with React cva()
Use the exportedcva() +cn() utilities to compose your own variant on top of the Byteion tokens.
import { cva, cn, type VariantProps } from '@byteion/react';
const myToast = cva('base classes…', {
variants: {
accent: { soft:'border-primary-200', loud:'border-primary-500' },
},
defaultVariants: { accent:'soft' },
});
type Props = React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof myToast>;
Compose with Vue cva()
Use the exportedcva() +cn() utilities inside standard Vue setup blocks.
<script setup lang="ts">
import { computed, useAttrs } from 'vue';
import { cva, type VariantProps } from '@byteion/vue';
interface Props { accent?:'soft' |'loud' }
const props = withDefaults(defineProps<Props>(), { accent:'soft' });
const attrs = useAttrs();
const myToast = cva('base classes…', {
variants: { accent: { soft:'border-primary-200', loud:'border-primary-500' } },
});
const cls = computed(() => myToast({ accent: props.accent, class: attrs.class as string | undefined }));
</script>
Runtime events
Byteion keeps framework APIs idiomatic: HTML uses DOM custom events, React uses callback props, and Vue uses emitted events / v-model updates.
HTML / JS events
bi:toast:hidebi:toast:show
React callbacks
No React callback events are declared by this adapter.
Vue emits
No Vue emitted events are declared by this adapter.
Remote / AJAX
This component does not implement Byteion JS remote loading. Use normal HTML form submission, framework state, or your application data layer around it.
API Reference
Programmatic API: toast.success(), toast.error(), toast.info().
HTML Data Attributes
data-bi-toast
Developer tips
Common mistakes
Production usage tips
data-bi-* attributes instead of styling hooks.
Premium examples
Advanced patterns available in Byteion Pro:
Related components
Unlock Premium Patterns
Get access to copy-paste ready Pro blocks, SaaS templates, and advanced data-tables built with this component.
Explore Pro Components