Toast
Temporary notifications inspired by noice.nvim, with configurable positioning and deduplication.
Toast
Design lines
✓
vue
1<Tabs defaultValue="tuix">2 <TabsList>3 <Tab value="tuix">TUIX</Tab>4 <Tab value="rubik">Rubik</Tab>5 </TabsList>6 <TabPanel value="tuix">7 <Toast message="Deployed ok" color="success" design="tuix" />8 </TabPanel>9 <TabPanel value="rubik">10 <Toast message="Deployed ok" color="success" design="rubik" />11 </TabPanel>12</Tabs>Demo
Basic (message / color)
Renders toasts with a message and a semantic color at each position.
vue
1<script setup lang="ts">2import { ref } from 'vue'3import { ToastContainer } from '@dowardev/herdrate-vue'4const items = ref([])56function showAt(position: string) {7 items.value.push({ id: Date.now(), message: 'Hello', color: 'primary', position })8}9function dismiss(id: number) {10 items.value = items.value.filter(t => t.id !== id)11}12</script>1314<template>15 <button @click="showAt('bottom-right')">bottom-right</button>16 <ToastContainer17 :toasts="items.filter(t => t.position === 'bottom-right')"18 :remove="dismiss"19 position="bottom-right"20 />21</template>Demo with useToast()
This demo uses the real useToast() composable from the package (singleton, shared state) — aligned with the flow you would copy to your project.
API
Toast
Props accepted by the Toast component.
| Prop | Type | Default | Description |
|---|---|---|---|
message | string | — | Toast content |
color | 'primary' | 'secondary' | 'tertiary' | 'success' | 'warning' | 'danger' | 'light' | 'medium' | 'dark' | 'primary' | Semantic toast color |
icon | string | '' | Custom icon (default: ▼/✓/●/✖) |
design | 'tuix' | 'rubik' | — (inherits from data-design) | Design line (or inherit from data-design). |
Events
| Event | Payload | Description |
|---|---|---|
close | void | Emitted when the close button is clicked. |
ToastContainer
Container that renders a toast list at a fixed screen position.
| Prop | Type | Default | Description |
|---|---|---|---|
toasts | Array<{id, message, color, icon, timestamp}> | — | List of toasts to display |
remove | (id: string) => void | — | Function to close a toast |
position | 'bottom-right' \| 'bottom-left' \| 'top-right' \| 'top-left' \| 'top-center' \| 'bottom-center' | 'bottom-right' | Screen position |
useToast()
Composable that returns the toast list and its helpers.
| Return | Type | Description |
|---|---|---|
toasts | Ref<Array<{id, message, color, icon, timestamp}>> | Reactive list of active toasts |
add | (opts: {message, color?, replace?, filter?}) => string | Adds a toast, returns ID |
remove | (id: string) => void | Removes a toast by ID |
toasts — each toast has this shape:
| Field | Type | Required | Description |
|---|---|---|---|
id | string | ✅ | Unique identifier |
message | string | ✅ | Message to display |
color | Color | ✅ | Semantic color |
icon | string | ✅ | Icon or emoji |
timestamp | number | ✅ | UNIX timestamp |
add(opts) — options accepted when creating a toast:
| Prop | Type | Default | Description |
|---|---|---|---|
message | string | — | Toast content |
color | 'primary' | 'secondary' | 'tertiary' | 'success' | 'warning' | 'danger' | 'light' | 'medium' | 'dark' | 'primary' | Semantic color |
replace | boolean | false | Replaces duplicate toast |
filter | string | — | Key to detect duplicates |
CSS Custom Properties
| Token | Default | Description |
|---|---|---|
--font-mono | "JetBrains Mono", ui-monospace, monospace | Monospace font stack for code-like content (key labels, log lines, chips). |
--accent | from theme (--ctp-latte-mauve / --ctp-mocha-mauve) | Accent color, mapped from the active semantic color. |
--bg-elevated | from theme (--ctp-latte-surface0 / --ctp-mocha-surface0) | Background of floating surfaces (modals, dropdowns, popovers). |
--border | from theme (--ctp-latte-surface0 / --ctp-mocha-surface0) | Outline and divider color for surfaces. |
--text | from theme (--ctp-latte-text / --ctp-mocha-text) | Primary text color used inside the component. |
--cp-ease | cubic-bezier(.4, 0, .2, 1) | Default easing curve for transitions. |
Ver Theming para la convención completa.