Anchor Design System

Notification banner3.0

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

Installation

npm i @tryg/ui-library

Usage

Individual only imports the desired component, and only needs to be included once within the application. Which is beneficial to keep the application size small.

Webcomponent
<script type="module">
  import { defineCustomElement } from '@tryg/ui-library/dist/components/anchor-notification-banner';
  defineCustomElement();
</script>
<anchor-notification-banner> This is an error message. </anchor-notification-banner>

Global only needs to be defined once in the application, but it will import all components even the ones that are not in use..

Webcomponent
<script type="module">
  import { defineCustomElements } from '@tryg/ui-library/dist/loader';
  defineCustomElements();
</script>
<anchor-notification-banner> This is an error message. </anchor-notification-banner>

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:

<anchor-notification-banner type="error"> This is an error message. </anchor-notification-banner>

Using the header slot

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

Example:

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

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:

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

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];
}

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