@aurodesignsystem/auro-banner
v5.1.1
Published
auro-banner HTML custom element
Readme
Banner
The <auro-banner> element provides users a flexible way to convey a summary of information. The primary elements of a banner include an image, and details.
The details are broken down into prefix, title, description, action, and disclaimer.
Do not use <auro-banner> as a primary source of information.
Use Cases
Use the <auro-banner> element to:
- grab the attention of a user
- direct your user to another resource for further information
Install
$ npm i @aurodesignsystem/auro-bannerDefine Dependency in Project
Defining the dependency within each project that is using the <auro-banner> component.
import "@aurodesignsystem/auro-banner";Use CDN
In cases where the project is not able to process JS assets, there are pre-processed assets available for use. Legacy browsers such as IE11 are no longer supported.
<script type="module" src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-banner@latest/+esm"></script>Basic Example
<auro-banner billboard>
<picture slot="displayImage">
<source srcset="https://picsum.photos/id/196/1124/800" media="(min-width: 1024px)">
<source srcset="https://picsum.photos/id/196/1124/1000" media="(min-width: 768px)">
<source srcset="https://picsum.photos/id/196/736/750" media="(min-width: 736px)">
<source srcset="https://picsum.photos/id/196/736/1400" media="(min-width: 375px)">
<source srcset="https://picsum.photos/id/196/320/700" media="(min-width: 320px)">
<img src="https://picsum.photos/id/196/225/550" alt="" />
</picture>
<img
slot="contentImage"
src="https://images.contentstack.io/v3/assets/blt2cefe12c88e9dd91/bltc1fa673bb196d177/6633f3de693c294c708b20de/oneworld-travel-bright-Horizontal-300.png"
alt="Random insert"/>
<p slot="description">
We’ll explain any additional costs before you book your car rental. More details on what’s included? Just check the Ts&Cs of any car.
</p>
<auro-hyperlink
type="cta"
variant="secondary"
href="/"
slot="action"
target="_blank">
More info
</auro-hyperlink>
</auro-banner>Custom Component Registration for Version Management
There are two key parts to every Auro component: the class and the custom element definition. The class defines the component’s behavior, while the custom element registers it under a specific name so it can be used in HTML.
When you install the component as described on the Install page, the class is imported automatically, and the component is registered globally for you.
However, if you need to load multiple versions of the same component on a single page (for example, when two projects depend on different versions), you can manually register the class under a custom element name to avoid conflicts.
You can do this by importing only the component class and using the register(name) method with a unique name:
// Import the class only
import { AuroBanner } from '@aurodesignsystem/auro-banner/class';
// Register with a custom name if desired
AuroBanner.register('custom-banner');This will create a new custom element <custom-banner> that behaves exactly like <auro-banner>, allowing both sets of components to coexist on the same page without interfering with each other.
<custom-banner billboard>
<picture slot="displayImage">
<source srcset="https://picsum.photos/id/196/1124/800" media="(min-width: 1024px)">
<source srcset="https://picsum.photos/id/196/1124/1000" media="(min-width: 768px)">
<source srcset="https://picsum.photos/id/196/736/750" media="(min-width: 736px)">
<source srcset="https://picsum.photos/id/196/736/1400" media="(min-width: 375px)">
<source srcset="https://picsum.photos/id/196/320/700" media="(min-width: 320px)">
<img src="https://picsum.photos/id/196/225/550" alt="" />
</picture>
<img
slot="contentImage"
src="https://images.contentstack.io/v3/assets/blt2cefe12c88e9dd91/bltc1fa673bb196d177/6633f3de693c294c708b20de/oneworld-travel-bright-Horizontal-300.png"
alt="Random insert"/>
<p slot="description">
We’ll explain any additional costs before you book your car rental. More details on what’s included? Just check the Ts&Cs of any car.
</p>
<auro-hyperlink
type="cta"
variant="secondary"
href="/"
slot="action"
target="_blank">
More info
</auro-hyperlink>
</custom-banner>