Skip to content

Layout

Positioning

The notifications' stream is a fixed-positioned element appended to the body using Vue Teleport.

When choosing *-right or *-left positions, notifications are placed at the edge of the window (minus the offsets).

In some specific layouts, you might prefer to visually keep the stream "inside" the app container or below a fixed header.

In such cases, you can use the following variables to control the inset of the stream:

Variable NameDescriptionDefault
--nv-root-widthMaximum width of the root wrapper.100%
--nv-root-topTop offset of the root wrapper.1.25rem
--nv-root-leftLeft offset of the root wrapper.1.25rem
--nv-root-rightRight offset of the root wrapper.1.25rem
--nv-root-bottomBottom offset of the root wrapper.1.25rem

Example

You've chose to position the stream at top-right but you'd rather place it below the fixed header and keep it "inside" your app container.

Layout

Assuming that:

  • The header is 90px high
  • The app container has a maximum width of 1280px plus a padding of 30px on each side
vue
<template>
  <Notivue v-slot="item">
    <Notification :item="item" />
  </Notivue>
</template>

<style>
:root {
  /* Your variables */
  --header-height: 90px;
  --container-padding: 30px;
  --container-width: 1280px;

  /* Set the maximum width of the stream */
  --nv-root-width: var(--container-width);

  /* Add the top padding and place it below the header */
  --nv-root-top: calc(var(--header-height) + var(--container-padding));

  /* Add the same left-right paddings of your app container */
  --nv-root-left: var(--container-padding);
  --nv-root-right: var(--container-padding);
}

/* Rules for mobile devices */
@media (max-width: 768px) {
  :root {
    --header-height: 60px;
    --container-padding: 20px;
  }
}
</style>

Centering on mobile devices

If you chose *-right or *-left positions, you might want to always center the notifications within a specific width:

vue
<template>
  <Notivue v-slot="item">
    <Notification :item="item" />
  </Notivue>
</template>

<style>
@media (max-width: 768px) {
  :root {
    --nv-root-x-align: center;
  }
}
</style>

Gap and z-index

Variable NameDescriptionDefault
--nv-zz-index of the notifications stream500
--nv-gapGap between notifications0.75rem
vue
<template>
  <Notivue v-slot="item">
    <Notification :item="item" />
  </Notivue>
</template>

<style>
:root {
  --nv-gap: 1rem;
  --nv-z: 9999;
}

/* Rules for mobile devices */
@media (max-width: 768px) {
  :root {
    --nv-gap: 0.5rem;
  }
}
</style>