Skip to content

Configuration

You configure global defaults under the snackbar key in nuxt.config.ts. These become the baseline for every message, and the <NuxtSnackbar /> host applies them automatically.

export default defineNuxtConfig({
modules: ['nuxt-snackbar'],
snackbar: {
bottom: true,
right: true,
duration: 5000,
},
})

The snackbar key accepts the underlying vue3-snackbar props:

OptionTypeDefaultDescription
topbooleanfalseRender at the top of the screen.
bottombooleantrueRender at the bottom of the screen.
leftbooleanfalseRender at the left.
rightbooleanfalseRender at the right.
startbooleanfalseRender at the inline-start (RTL-aware left).
endbooleanfalseRender at the inline-end (RTL-aware right).
successstring#4caf50Base color for success messages.
errorstring#ff5252Base color for error messages.
warningstring#fb8c00Base color for warning messages.
infostring#2196f3Base color for info messages.
messageTextColorstring(theme)Text color for the default (untyped) message.
messageIconColorstring(theme)Icon color for the default message.
durationnumber4000Default milliseconds a message stays before auto-dismiss.
groupsbooleantrueGroup messages that share the same group key.
limitnumber0Maximum messages shown at once (0 = unlimited).
reversebooleanfalseReverse the display order of messages.
densebooleanfalseReduce vertical padding for a more compact message.
shadowboolean | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'trueDrop shadow on messages.
zIndexnumber9999z-index of the snackbar container.
messageClassstring''Extra CSS class added to every message.
messageActionClassstring''Extra CSS class for the action area.
dismissOnActionClickbooleanfalseAuto-dismiss a message when its action is clicked.
border'top' | 'bottom' | 'left' | 'right' | 'start' | 'end'''Use border-style messages with the colored accent on the given edge.
backgroundColorstringcurrentColorBackground color for border-style messages.
baseBackgroundColorstring#ffffffBase background for border-style messages.
backgroundOpacitynumber | string0.12Background opacity for border-style messages.
contentWidthstring(auto)CSS width for the snackbar content.
attachstring | HTMLElement(body)Element to attach the snackbar container to.
iconPresetsobject{}Per-type icon overrides (passed as vue3-icon props).

Out of the box, the module applies a small set of opinionated defaults so notifications look right with no configuration:

  • bottom: true
  • duration: 4000
  • groups: true
  • shadow: true
  • zIndex: 9999
  • The four type colors: success #4caf50, error #ff5252, warning #fb8c00, info #2196f3.

Everything else falls back to vue3-snackbar’s own defaults. Anything you set in the snackbar key overrides these.

Position is controlled by combining the boolean edge options. They stack — set both a vertical and a horizontal edge to anchor to a corner:

export default defineNuxtConfig({
modules: ['nuxt-snackbar'],
snackbar: {
bottom: true,
right: true, // bottom-right corner
},
})

See Positioning for more layouts, and Custom Styling for border-style messages and color overrides.