Notification Banner3.0
Installation
npm i @tryg/vue-ui-libraryUsage
Install the component library as a Vue plugin. This globally registers all Anchor components.
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');<template>
<anchor-notification-banner>
This is an error message.
</anchor-notification-banner>
</template>Import only the components you need for optimal bundle size.
<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>Using the link slot
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:
| Variable | Description |
|---|---|
--border | Border style for the notification banner |
--notification-banner-background-color | Background color of the notification banner |
--notification-banner-border-color | Border color of the notification banner |
--notification-banner-border-width | Width of the notification banner border |
--notification-banner-font-family | Font family for the notification banner text |
--notification-banner-font-size | Font size for the notification banner text |
--notification-banner-font-weight | Font weight for the notification banner text |
--notification-banner-icon-color | Icon color in the notification banner |
--notification-banner-inline-spacing | Spacing between inline elements in the notification banner |
--notification-banner-line-height | Line height for the notification banner text |
--notification-banner-max-width | Maximum width of the notification banner |
--notification-banner-text-color | Text 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
typeprop (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-labelprop 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
| Property | Attribute | Description | Type | Default |
|---|---|---|---|---|
canClose | can-close | boolean | true | |
closeButtonAriaLabel | close-button-aria-label | arialabel for close button icon in banner- used for accessibility | string | undefined |
iconSize | icon-size | "large" | "medium" | "small" | "xlarge" | "xsmall" | 'small' | |
type | type | The type of notification to be displayed. Options are Error, Info, Success, and Warning. | "error" | "info" | "success" | "warning" | undefined |
uuid | uuid | Give this instance of notification-inline a custom ID, or keep the default. | string | uuidv4() |
Events
| Event | Description | Type |
|---|---|---|
closed | CustomEvent<any> |
Methods
close() => Promise<void>
Returns
Type: Promise<void>
CSS Custom Properties
| Name | Description |
|---|---|
--border | Border style for the notification banner. |
--notification-banner-background-color | Background color of the notification banner. |
--notification-banner-border-color | Border color of the notification banner. |
--notification-banner-border-width | Width of the notification banner border. |
--notification-banner-font-family | Font family for the notification banner text. |
--notification-banner-font-size | Font size for the notification banner text. |
--notification-banner-font-weight | Font weight for the notification banner text. |
--notification-banner-icon-color | Icon color in the notification banner. |
--notification-banner-inline-spacing | Spacing between inline elements in the notification banner. |
--notification-banner-line-height | Line height for the notification banner text. |
--notification-banner-max-width | Maximum width of the notification banner. |
--notification-banner-text-color | Text 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:4pxBuilt with StencilJS
Tooltip
Tooltips display a brief, informative message that appears when a user interacts with an element.
Notification Inline
The notification-inline 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.
