Usage
Use the useToast composable to display a toast in your application.
App component which uses our Toaster component which uses the ToastProvider component from Reka UI.Title
Pass a title field to the toast.add method to display a title.
Description
Pass a description field to the toast.add method to display a description.
Icon
Pass an icon field to the toast.add method to display an Icon.
Avatar
Pass an avatar field to the toast.add method to display an Avatar.
Color
Pass a color field to the toast.add method to change the color of the Toast.
Close
Pass a close field to customize or hide the close Button (with false value).
Close Icon
Pass a closeIcon field to customize the close button Icon.
Actions
Pass an actions field to add some Button actions to the Toast.
Progress
Pass a progress field to customize or hide the Progress bar (with false value).
progress.color field.Orientation
Pass an orientation field to the toast.add method to change the orientation of the Toast.
Examples
Change global position
Change the toaster.position prop on the App component to change the position of the toasts.
<script setup lang="ts">
const toaster = { position: 'bottom-right' }
</script>
<template>
<B24App :toaster="toaster">
<NuxtPage />
</B24App>
</template>
AppConfig to configure the position prop of the Toaster component globally.Change global duration
Change the toaster.duration prop on the App component to change the duration of the toasts.
<script setup lang="ts">
const toaster = { duration: 5000 }
</script>
<template>
<B24App :toaster="toaster">
<NuxtPage />
</B24App>
</template>
AppConfig to configure the duration prop of the Toaster component globally.Change global max Soon
Change the toaster.max prop on the App component to change the max number of toasts displayed at once.
<script setup lang="ts">
const toaster = { max: 3 }
</script>
<template>
<B24App :toaster="toaster">
<NuxtPage />
</B24App>
</template>
Stacked toasts
Set the toaster.expand prop to false on the App component to display stacked toasts (inspired by Sonner).
<script setup lang="ts">
const toaster = { expand: true }
</script>
<template>
<B24App :toaster="toaster">
<NuxtPage />
</B24App>
</template>
AppConfig to configure the expand prop of the Toaster component globally.API
Props
Slots
Emits
Expose
When accessing the component via a template ref, you can use the following:
Theme
export default defineAppConfig({
b24ui: {
toast: {
slots: {
root: 'dark relative group overflow-hidden rounded-[26px] py-3.5 ps-6 pe-4 flex items-center gap-2.5 focus-visible:outline-(length:--ui-design-outline-stroke-weight) focus-visible:outline-offset-2 focus-visible:outline-(--ui-color-design-outline-content-divider) font-[family-name:var(--ui-font-family-primary)] bg-(--ui-color-bg-content-primary)/80 text-(--ui-color-design-plain-na-focused-content) text-(length:--ui-font-size-sm) font-(--ui-font-weight-normal)',
wrapper: 'w-0 flex-1 flex flex-col',
title: 'font-(--ui-font-weight-medium)',
description: '',
icon: 'shrink-0 size-6 text-(--b24ui-border-color)',
avatar: 'shrink-0',
avatarSize: 'xl',
actions: 'flex gap-1.5 shrink-0',
progress: 'absolute inset-x-0 bottom-0',
close: 'p-0'
},
variants: {
color: {
'air-primary': {
root: 'style-filled'
},
'air-primary-success': {
root: 'style-filled-success'
},
'air-primary-alert': {
root: 'style-filled-alert'
},
'air-primary-copilot': {
root: 'style-filled-copilot'
},
'air-primary-warning': {
root: 'style-filled-warning'
},
'air-secondary': {
root: 'style-filled-inverted'
},
default: {
root: 'old-style-default'
},
danger: {
root: 'old-style-danger'
},
success: {
root: 'old-style-success'
},
warning: {
root: 'old-style-warning'
},
primary: {
root: 'old-style-primary'
},
secondary: {
root: 'old-style-secondary'
},
collab: {
root: 'old-style-collab'
},
ai: {
root: 'old-style-ai'
}
},
orientation: {
horizontal: {
root: 'items-center',
actions: 'items-center'
},
vertical: {
root: 'items-center',
actions: 'items-start mt-1'
}
},
title: {
true: {
description: 'mt-1'
}
}
},
defaultVariants: {
color: 'air-secondary'
}
}
}
})
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import bitrix24UIPluginVite from '@bitrix24/b24ui-nuxt/vite'
export default defineConfig({
plugins: [
vue(),
bitrix24UIPluginVite({
b24ui: {
toast: {
slots: {
root: 'dark relative group overflow-hidden rounded-[26px] py-3.5 ps-6 pe-4 flex items-center gap-2.5 focus-visible:outline-(length:--ui-design-outline-stroke-weight) focus-visible:outline-offset-2 focus-visible:outline-(--ui-color-design-outline-content-divider) font-[family-name:var(--ui-font-family-primary)] bg-(--ui-color-bg-content-primary)/80 text-(--ui-color-design-plain-na-focused-content) text-(length:--ui-font-size-sm) font-(--ui-font-weight-normal)',
wrapper: 'w-0 flex-1 flex flex-col',
title: 'font-(--ui-font-weight-medium)',
description: '',
icon: 'shrink-0 size-6 text-(--b24ui-border-color)',
avatar: 'shrink-0',
avatarSize: 'xl',
actions: 'flex gap-1.5 shrink-0',
progress: 'absolute inset-x-0 bottom-0',
close: 'p-0'
},
variants: {
color: {
'air-primary': {
root: 'style-filled'
},
'air-primary-success': {
root: 'style-filled-success'
},
'air-primary-alert': {
root: 'style-filled-alert'
},
'air-primary-copilot': {
root: 'style-filled-copilot'
},
'air-primary-warning': {
root: 'style-filled-warning'
},
'air-secondary': {
root: 'style-filled-inverted'
},
default: {
root: 'old-style-default'
},
danger: {
root: 'old-style-danger'
},
success: {
root: 'old-style-success'
},
warning: {
root: 'old-style-warning'
},
primary: {
root: 'old-style-primary'
},
secondary: {
root: 'old-style-secondary'
},
collab: {
root: 'old-style-collab'
},
ai: {
root: 'old-style-ai'
}
},
orientation: {
horizontal: {
root: 'items-center',
actions: 'items-center'
},
vertical: {
root: 'items-center',
actions: 'items-start mt-1'
}
},
title: {
true: {
description: 'mt-1'
}
}
},
defaultVariants: {
color: 'air-secondary'
}
}
}
})
]
})