Skip to content

Positioning

Position is set with the position option, and how long a toast stays is set with autoClose (in milliseconds). You can configure both globally for every toast, or override them for a single call.

Set a default corner for every toast in nuxt.config.ts:

nuxt.config.ts
export default defineNuxtConfig({
modules: ['nuxt-toastify'],
toastify: {
position: 'bottom-center',
},
})

The available positions are: top-left, top-center, top-right, bottom-left, bottom-center, and bottom-right.

Override the position for a single toast. Use the ToastifyOption.POSITION constants for typo-safe values:

<script setup lang="ts">
function notify() {
useToastify('Top left', {
position: ToastifyOption.POSITION.TOP_LEFT,
})
useToastify('Bottom right', {
position: ToastifyOption.POSITION.BOTTOM_RIGHT,
})
}
</script>
<template>
<button @click="notify">Notify</button>
</template>

The plain strings ('top-left', 'bottom-right', …) work too — the constants are just a convenience.

autoClose is the number of milliseconds a toast stays before it auto-dismisses. The module default is 5000 (5 seconds). Change it globally:

nuxt.config.ts
export default defineNuxtConfig({
modules: ['nuxt-toastify'],
toastify: {
autoClose: 3000, // every toast stays 3 seconds by default
},
})

Pass autoClose to useToastify() to override the global default for just that toast:

// This one stays much longer than the global default
useToastify.info('Read me carefully.', {
autoClose: 12000,
})

Set autoClose: false to keep a toast open until it’s clicked or removed programmatically:

const id = useToastify('Action required — click to dismiss.', {
autoClose: false,
})
// remove it yourself when appropriate:
// useToastify.remove(id)