Notification Inline3.0
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.
Ads by Tryg Careers
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-inline>
This is an error message.
</anchor-notification-inline>
</template>Import only the components you need for optimal bundle size.
<script setup>
import { AnchorNotificationInline } from '@tryg/vue-ui-library';
</script>
<template>
<anchor-notification-inline>
This is an error message.
</anchor-notification-inline>
</template>Error notification
Header slot
You can give the notification a bold header by using the header slot.
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:
Accessibility
- Uses
role="alert"for error and warning types, androle="status"for info and success types, so screen readers announce them appropriately. - The
typeprop determines the ARIA role, allowing assistive technology to convey the correct level of urgency. - Icon visually conveys severity (alert-triangle for error, info for info, check-circle for success, alert-circle for warning).
- Supports
aria-liveregions for dynamically inserted notifications, ensuring screen reader users are notified of new content. - For dynamically added notifications, consider using
aria-live="assertive"on error messages to interrupt the user's current task.
CSS variables
The following CSS custom properties are exposed:
| Variable | Description |
|---|---|
--background-color | DEPRECATED: kept for backwards compatibility, but will be removed by April 2024 |
--border-color | DEPRECATED: kept for backwards compatibility, but will be removed by April 2024 |
--border-radius | DEPRECATED: kept for backwards compatibility, but will be removed by April 2024 |
--border-width | DEPRECATED: kept for backwards compatibility, but will be removed by April 2024 |
--gap | DEPRECATED: kept for backwards compatibility, but will be removed by April 2024 |
--inline-icon-color | DEPRECATED: kept for backwards compatibility, but will be removed by April 2024 |
--lineheight | DEPRECATED: kept for backwards compatibility, but will be removed by April 2024 |
--notification-inline-background-color | Set the background color of the <anchor-notification-inline> |
--notification-inline-border-color | Set the border color of the <anchor-notification-inline> |
--notification-inline-border-radius | Set the border radius of the <anchor-notification-inline> |
--notification-inline-border-width | Set the border width of the <anchor-notification-inline> |
--notification-inline-gap | Set the gap width of the <anchor-notification-inline> |
--notification-inline-icon-color | Set the color of the inline icon in the <anchor-notification-inline> |
--notification-inline-lineheight | Set the lineheight of the <anchor-notification-inline> |
--notification-inline-link-color | Set the color of the links in the <anchor-notification-inline> |
--notification-inline-text-color | Set the text color of the <anchor-notification-inline> |
--notification-inline-width | Set the width of the <anchor-notification-inline> |
--text-color | DEPRECATED: kept for backwards compatibility, but will be removed by April 2024 |
API
Inline notification
Properties
| Property | Attribute | Description | Type | Default |
|---|---|---|---|---|
type | type | The type of alert to display. Can be 'error', 'info', 'success', or 'warning'. | "error" | "info" | "success" | "warning" | undefined |
uuid | uuid | Give this instance of notification-inline a custom ID, or keep the default. | string | uuidv4() |
CSS Custom Properties
| Name | Description |
|---|---|
--background-color | DEPRECATED: kept for backwards compatibility, but will be removed by April 2024 |
--border-color | DEPRECATED: kept for backwards compatibility, but will be removed by April 2024 |
--border-radius | DEPRECATED: kept for backwards compatibility, but will be removed by April 2024 |
--border-width | DEPRECATED: kept for backwards compatibility, but will be removed by April 2024 |
--gap | DEPRECATED: kept for backwards compatibility, but will be removed by April 2024 |
--inline-icon-color | DEPRECATED: kept for backwards compatibility, but will be removed by April 2024 |
--lineheight | DEPRECATED: kept for backwards compatibility, but will be removed by April 2024 |
--notification-inline-background-color | Set the background color of the |
--notification-inline-border-color | Set the border color of the |
--notification-inline-border-radius | Set the border radius of the |
--notification-inline-border-width | Set the border width of the |
--notification-inline-gap | Set the gap width of the |
--notification-inline-icon-color | Set the color of the inline icon in the |
--notification-inline-lineheight | Set the lineheight of the |
--notification-inline-link-color | Set the color of the links in the |
--notification-inline-text-color | Set the text color of the |
--notification-inline-width | Set the width of the |
--text-color | DEPRECATED: kept for backwards compatibility, but will be removed by April 2024 |
Dependencies
Depends on
Graph
graph TD;
anchor-notification-inline --> anchor-icon
style anchor-notification-inline fill:#f9f,stroke:#333,stroke-width:4pxBuilt with StencilJS
