Anchor Design System

Notification Banner3.0

The notification-banner is used to announce pagewise or sitewise information.

Installation

npm i @tryg/vue-ui-library

Usage

Install the component library as a Vue plugin. This globally registers all Anchor components.

main.js
import { createApp } from 'vue';
import { ComponentLibrary } from '@tryg/vue-ui-library';
import App from './App.vue';

const app = createApp(App);
app.use(ComponentLibrary);
app.mount('#app');
YourComponent.vue
<template>
  <anchor-notification-banner>
    This is an error message.
  </anchor-notification-banner>
</template>

Import only the components you need for optimal bundle size.

YourComponent.vue
<script setup>
import { AnchorNotificationBanner } from '@tryg/vue-ui-library';
</script>
<template>
  <anchor-notification-banner>
    This is an error message.
  </anchor-notification-banner>
</template>

The notification-banner component is a simple alert component that can display a variety of different types of messages, including error, info, success, and warning messages. It also displays an icon corresponding to the type of message being displayed.

The notification-banner takes up the full width of the page and is fixed to the top of the page. It sits "on top" of the page content, and does not need to fit in the flow of the page.

Error notification banner

Use the component in your template like this:

Using the header slot

You can give the notification a bold header by using the header slot.

Example:

<template>
  <anchor-notification-banner>
    <div slot="header">Custom Header</div>
  </anchor-notification-banner>
</template>

You can give the notification a link by using the link slot. Remember that you have to use an <a> tag in the slot. And you have to use the slot="link" attribute on the <a> tag.

Example:

<template>
  <anchor-notification-banner>
    <a slot="link" href="http://your-link-here">Learn more</a>
  </anchor-notification-banner>
</template>

Set the max-width of the Notification Banner

You can set the max-width of the Notification Banner content by using the --notification-banner-max-width CSS variable.

Example:

anchor-notification-banner {
  --notification-banner-max-width: [your-max-width-here];
}

CSS variables

The following CSS custom properties are exposed:

VariableDescription
--borderBorder style for the notification banner
--notification-banner-background-colorBackground color of the notification banner
--notification-banner-border-colorBorder color of the notification banner
--notification-banner-border-widthWidth of the notification banner border
--notification-banner-font-familyFont family for the notification banner text
--notification-banner-font-sizeFont size for the notification banner text
--notification-banner-font-weightFont weight for the notification banner text
--notification-banner-icon-colorIcon color in the notification banner
--notification-banner-inline-spacingSpacing between inline elements in the notification banner
--notification-banner-line-heightLine height for the notification banner text
--notification-banner-max-widthMaximum width of the notification banner
--notification-banner-text-colorText color in the notification banner

Accessibility

  • The notification banner uses the role="alert" ARIA role, ensuring screen readers announce its content immediately when it appears.
  • Use the type prop (error, info, success, warning) to convey the severity of the notification. The corresponding icon is decorative and should not be announced separately.
  • The close button supports keyboard interaction with Tab to focus and Enter / Space to activate.
  • Use the close-button-aria-label prop to provide a custom accessible label for the close button. The default label may not be sufficient in all contexts.

API

anchor-notification-banner

Properties

PropertyAttributeDescriptionTypeDefault
canClosecan-closebooleantrue
closeButtonAriaLabelclose-button-aria-labelarialabel for close button icon in banner- used for accessibilitystringundefined
iconSizeicon-size"large" | "medium" | "small" | "xlarge" | "xsmall"'small'
typetypeThe type of notification to be displayed. Options are Error, Info, Success, and Warning."error" | "info" | "success" | "warning"undefined
uuiduuidGive this instance of notification-inline a custom ID, or keep the default.stringuuidv4()

Events

EventDescriptionType
closedCustomEvent<any>

Methods

close() => Promise<void>

Returns

Type: Promise<void>

CSS Custom Properties

NameDescription
--borderBorder style for the notification banner.
--notification-banner-background-colorBackground color of the notification banner.
--notification-banner-border-colorBorder color of the notification banner.
--notification-banner-border-widthWidth of the notification banner border.
--notification-banner-font-familyFont family for the notification banner text.
--notification-banner-font-sizeFont size for the notification banner text.
--notification-banner-font-weightFont weight for the notification banner text.
--notification-banner-icon-colorIcon color in the notification banner.
--notification-banner-inline-spacingSpacing between inline elements in the notification banner.
--notification-banner-line-heightLine height for the notification banner text.
--notification-banner-max-widthMaximum width of the notification banner.
--notification-banner-text-colorText color in the notification banner.

Dependencies

Depends on

Graph

graph TD;
  anchor-notification-banner --> anchor-icon
  anchor-notification-banner --> anchor-icon-button
  style anchor-notification-banner fill:#f9f,stroke:#333,stroke-width:4px

Built with StencilJS

On this page