Skip to content

Sonner

An opinionated toast component for Vue.

Examples

Default

vue
<script setup>
import { Toaster } from '@empathyds/vue'
import { toast } from 'vue-sonner'
import { Button } from '@empathyds/vue'
</script>

<template>
  <Toaster />
  <Button
    variant="outline"
    @click="toast('Event has been created', {
      description: 'Sunday, December 03, 2023 at 9:00 AM',
      action: {
        label: 'Undo',
        onClick: () => console.log('Undo'),
      },
    })"
  >
    Show Toast
  </Button>
</template>
</template>

Installation

bash
pnpm add vue-sonner
bash
npm install vue-sonner
bash
yarn add vue-sonner
bash
bun add vue-sonner

Props

Toaster

PropTypeDefaultDescription
position'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right''bottom-right'The position of the toast
expandbooleanfalseWhether to expand the toast on hover
durationnumber4000The duration of the toast
visible-toastsnumber3The number of visible toasts
close-buttonbooleanfalseWhether to show the close button
rich-colorsbooleanfalseWhether to allow rich colors
offsetnumber | string-The offset of the toast
dir'ltr' | 'rtl' | 'auto''auto'The direction of the toast
theme'light' | 'dark' | 'system''system'The theme of the toast

Slots

Toaster

SlotDescription
success-iconThe success icon
info-iconThe info icon
warning-iconThe warning icon
error-iconThe error icon
loading-iconThe loading icon