Informs visitors about important changes or persistent conditions. Use this component if you need to communicate to visitors in a prominent way. Banners are placed at the top of the page or section they apply to, and below the page or section header.
vf-banner vf-banner--noticevf-banner vf-banner--phasevf-banner vf-banner--alert vf-banner--info This replaces vf-banner--phasevf-banner vf-banner--alert vf-banner--successvf-banner vf-banner--alert vf-banner--alertvf-banner vf-banner--alert vf-banner--warningnote: The vf-banner--alert variants include the option to dismiss the banner. This is currently a 'bring your own JavaScript' button. To include a close button in the markup you need to make sure you have the variable banner__dismissable set to true:
banner__dismissable: true
--modal variantLike all JS-enabled components in the Visual Framework, if you wish to use the bundled JS, you need to include JS data attributes, here is an overview of what the options are for the vf-banner--modal variant.
dismissible: standard messaging typeblocking: full screenpersistent: no close buttonblocking banner state"y""myServiceName""0.1" Incrementing this string will invalidate old cookies."<a href='#'>Optional button</a><a target='_blank' href='#'>New tab button</a>"> This HTML string will be converted into VF markup for extra buttons. Optional..innerHTML of this element will be used as the markup for the message itselfDepending on your environment you'll want to use render or include. As a rule of thumb: server-side use include, precompiled browser use render. If you're using vf-eleventy you should use include.
includeYou'll need to pass a context object from your code or Yaml file (example), as well as the path to the Nunjucks template. Nunjucks' include is an abstraction of render and provides some additional portability.
{% set context fromYourYamlFile %}
- or -
{% set context = {
"component-type": "container",
"data-service-id": "MyService",
"data-protection-version": 0.1,
"banner__text": "I agree, dismiss this banner",
"banner__link": null,
"banner__inline_href": "JavaScript:Void(0);",
"alert_icon_text": "dismiss",
"banner__info": true,
"banner__dismissable": true,
"banner__message": "Here is some very, <em>very</em> <a class=\"vf-banner__link\" href=\"JavaScript:Void(0);\">important information</a>"
}
%}
{% include "../path_to/vf-banner/vf-banner.njk" %}
renderThis approach is best for bare-bones Nunjucks environments, such as precompiled templates with the Nunjucks slim runtime where include is not be available.
{% render '@vf-banner', {
"component-type": "container",
"data-service-id": "MyService",
"data-protection-version": 0.1,
"banner__text": "I agree, dismiss this banner",
"banner__link": null,
"banner__inline_href": "JavaScript:Void(0);",
"alert_icon_text": "dismiss",
"banner__info": true,
"banner__dismissable": true,
"banner__message": "Here is some very, <em>very</em> <a class=\"vf-banner__link\" href=\"JavaScript:Void(0);\">important information</a>"
} %}
<div class="vf-banner vf-banner--alert vf-banner--info">
<div class="vf-banner__content">
<p class="vf-banner__text">Here is some very, <em>very</em> <a class="vf-banner__link" href="JavaScript:Void(0);">important information</a></p>
<button role="button" aria-label="close notification banner" class="vf-button vf-button--icon vf-button--dismiss | vf-banner__button">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<title>dismiss banner</title>
<path d="M14.3,12.179a.25.25,0,0,1,0-.354l9.263-9.262A1.5,1.5,0,0,0,21.439.442L12.177,9.7a.25.25,0,0,1-.354,0L2.561.442A1.5,1.5,0,0,0,.439,2.563L9.7,11.825a.25.25,0,0,1,0,.354L.439,21.442a1.5,1.5,0,0,0,2.122,2.121L11.823,14.3a.25.25,0,0,1,.354,0l9.262,9.263a1.5,1.5,0,0,0,2.122-2.121Z" />
</svg>
</button>
</div>
</div>
Depending on your environment you'll want to use render or include. As a rule of thumb: server-side use include, precompiled browser use render. If you're using vf-eleventy you should use include.
includeYou'll need to pass a context object from your code or Yaml file (example), as well as the path to the Nunjucks template. Nunjucks' include is an abstraction of render and provides some additional portability.
{% set context fromYourYamlFile %}
- or -
{% set context = {
"component-type": "container",
"data-service-id": "MyService",
"data-protection-version": 0.1,
"banner__text": "I agree, dismiss this banner",
"banner__link": null,
"banner__inline_href": "JavaScript:Void(0);",
"alert_icon_text": "dismiss",
"banner__warning": true,
"banner__dismissable": true,
"banner__message": "Easy now, easy does it. <a class=\"vf-banner__link\" href=\"JavaScript:Void(0);\">link example</a>"
}
%}
{% include "../path_to/vf-banner/vf-banner.njk" %}
renderThis approach is best for bare-bones Nunjucks environments, such as precompiled templates with the Nunjucks slim runtime where include is not be available.
{% render '@vf-banner', {
"component-type": "container",
"data-service-id": "MyService",
"data-protection-version": 0.1,
"banner__text": "I agree, dismiss this banner",
"banner__link": null,
"banner__inline_href": "JavaScript:Void(0);",
"alert_icon_text": "dismiss",
"banner__warning": true,
"banner__dismissable": true,
"banner__message": "Easy now, easy does it. <a class=\"vf-banner__link\" href=\"JavaScript:Void(0);\">link example</a>"
} %}
<div class="vf-banner vf-banner--alert vf-banner--warning">
<div class="vf-banner__content">
<p class="vf-banner__text">Easy now, easy does it. <a class="vf-banner__link" href="JavaScript:Void(0);">link example</a></p>
<button role="button" aria-label="close notification banner" class="vf-button vf-button--icon vf-button--dismiss | vf-banner__button">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<title>dismiss banner</title>
<path d="M14.3,12.179a.25.25,0,0,1,0-.354l9.263-9.262A1.5,1.5,0,0,0,21.439.442L12.177,9.7a.25.25,0,0,1-.354,0L2.561.442A1.5,1.5,0,0,0,.439,2.563L9.7,11.825a.25.25,0,0,1,0,.354L.439,21.442a1.5,1.5,0,0,0,2.122,2.121L11.823,14.3a.25.25,0,0,1,.354,0l9.262,9.263a1.5,1.5,0,0,0,2.122-2.121Z" />
</svg>
</button>
</div>
</div>
Depending on your environment you'll want to use render or include. As a rule of thumb: server-side use include, precompiled browser use render. If you're using vf-eleventy you should use include.
includeYou'll need to pass a context object from your code or Yaml file (example), as well as the path to the Nunjucks template. Nunjucks' include is an abstraction of render and provides some additional portability.
{% set context fromYourYamlFile %}
- or -
{% set context = {
"component-type": "container",
"data-service-id": "MyService",
"data-protection-version": 0.1,
"banner__text": "I agree, dismiss this banner",
"banner__link": null,
"banner__inline_href": "JavaScript:Void(0);",
"alert_icon_text": "dismiss",
"banner__danger": true,
"banner__dismissable": true,
"banner__message": "Oh dear, what have you done? <a class=\"vf-banner__link\" href=\"JavaScript:Void(0);\">link example</a>"
}
%}
{% include "../path_to/vf-banner/vf-banner.njk" %}
renderThis approach is best for bare-bones Nunjucks environments, such as precompiled templates with the Nunjucks slim runtime where include is not be available.
{% render '@vf-banner', {
"component-type": "container",
"data-service-id": "MyService",
"data-protection-version": 0.1,
"banner__text": "I agree, dismiss this banner",
"banner__link": null,
"banner__inline_href": "JavaScript:Void(0);",
"alert_icon_text": "dismiss",
"banner__danger": true,
"banner__dismissable": true,
"banner__message": "Oh dear, what have you done? <a class=\"vf-banner__link\" href=\"JavaScript:Void(0);\">link example</a>"
} %}
<div class="vf-banner vf-banner--alert vf-banner--danger">
<div class="vf-banner__content">
<p class="vf-banner__text">Oh dear, what have you done? <a class="vf-banner__link" href="JavaScript:Void(0);">link example</a></p>
<button role="button" aria-label="close notification banner" class="vf-button vf-button--icon vf-button--dismiss | vf-banner__button">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<title>dismiss banner</title>
<path d="M14.3,12.179a.25.25,0,0,1,0-.354l9.263-9.262A1.5,1.5,0,0,0,21.439.442L12.177,9.7a.25.25,0,0,1-.354,0L2.561.442A1.5,1.5,0,0,0,.439,2.563L9.7,11.825a.25.25,0,0,1,0,.354L.439,21.442a1.5,1.5,0,0,0,2.122,2.121L11.823,14.3a.25.25,0,0,1,.354,0l9.262,9.263a1.5,1.5,0,0,0,2.122-2.121Z" />
</svg>
</button>
</div>
</div>
Depending on your environment you'll want to use render or include. As a rule of thumb: server-side use include, precompiled browser use render. If you're using vf-eleventy you should use include.
includeYou'll need to pass a context object from your code or Yaml file (example), as well as the path to the Nunjucks template. Nunjucks' include is an abstraction of render and provides some additional portability.
{% set context fromYourYamlFile %}
- or -
{% set context = {
"component-type": "container",
"data-service-id": "MyService",
"data-protection-version": 0.1,
"banner__text": "I agree, dismiss this banner",
"banner__link": null,
"banner__inline_href": "JavaScript:Void(0);",
"alert_icon_text": "dismiss",
"banner__success": true,
"banner__dismissable": true,
"banner__message": "Congratulations! You have made something <a class=\"vf-banner__link\" href=\"JavaScript:Void(0);\">awesome</a>!"
}
%}
{% include "../path_to/vf-banner/vf-banner.njk" %}
renderThis approach is best for bare-bones Nunjucks environments, such as precompiled templates with the Nunjucks slim runtime where include is not be available.
{% render '@vf-banner', {
"component-type": "container",
"data-service-id": "MyService",
"data-protection-version": 0.1,
"banner__text": "I agree, dismiss this banner",
"banner__link": null,
"banner__inline_href": "JavaScript:Void(0);",
"alert_icon_text": "dismiss",
"banner__success": true,
"banner__dismissable": true,
"banner__message": "Congratulations! You have made something <a class=\"vf-banner__link\" href=\"JavaScript:Void(0);\">awesome</a>!"
} %}
<div class="vf-banner vf-banner--alert vf-banner--success">
<div class="vf-banner__content">
<p class="vf-banner__text">Congratulations! You have made something <a class="vf-banner__link" href="JavaScript:Void(0);">awesome</a>!</p>
<button role="button" aria-label="close notification banner" class="vf-button vf-button--icon vf-button--dismiss | vf-banner__button">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<title>dismiss banner</title>
<path d="M14.3,12.179a.25.25,0,0,1,0-.354l9.263-9.262A1.5,1.5,0,0,0,21.439.442L12.177,9.7a.25.25,0,0,1-.354,0L2.561.442A1.5,1.5,0,0,0,.439,2.563L9.7,11.825a.25.25,0,0,1,0,.354L.439,21.442a1.5,1.5,0,0,0,2.122,2.121L11.823,14.3a.25.25,0,0,1,.354,0l9.262,9.263a1.5,1.5,0,0,0,2.122-2.121Z" />
</svg>
</button>
</div>
</div>
Depending on your environment you'll want to use render or include. As a rule of thumb: server-side use include, precompiled browser use render. If you're using vf-eleventy you should use include.
includeYou'll need to pass a context object from your code or Yaml file (example), as well as the path to the Nunjucks template. Nunjucks' include is an abstraction of render and provides some additional portability.
{% set context fromYourYamlFile %}
- or -
{% set context = {
"component-type": "container",
"data-service-id": "MyService",
"data-protection-version": 0.1,
"banner__text": "I agree, dismiss this banner",
"banner__link": null,
"banner__inline_href": "JavaScript:Void(0);",
"alert_icon_text": "dismiss"
}
%}
{% include "../path_to/vf-banner/vf-banner.njk" %}
renderThis approach is best for bare-bones Nunjucks environments, such as precompiled templates with the Nunjucks slim runtime where include is not be available.
{% render '@vf-banner', {
"component-type": "container",
"data-service-id": "MyService",
"data-protection-version": 0.1,
"banner__text": "I agree, dismiss this banner",
"banner__link": null,
"banner__inline_href": "JavaScript:Void(0);",
"alert_icon_text": "dismiss"
} %}
<!-- dismissible banner -->
<div class="vf-banner vf-banner--fixed vf-banner--bottom vf-banner--notice" data-vf-js-banner data-vf-js-banner-state="dismissible" data-vf-js-banner-button-text="I agree, dismiss this banner" data-vf-js-banner-cookie-name="NaN" data-vf-js-banner-cookie-version="NaN" data-vf-js-banner-extra-button="<a href='#'>Optional button</a><a target='_blank' href='#'>New tab button</a>" data-vf-js-banner-auto-accept="false">
<div class="vf-banner__content | vf-grid" data-vf-js-banner-text>
<p class="vf-banner__text vf-banner__text--lg">
This website uses cookies, and the limiting processing of your personal data to function. By using the site you are agreeing to this as outlined in our <a class="vf-banner__link" href="JavaScript:Void(0);">Privacy Notice</a> and <a class="vf-banner__link" href="JavaScript:Void(0);">Terms Of Use</a>.
</p>
</div>
</div>
<!-- persistent banner -->
<!-- <div class="vf-banner vf-banner--fixed vf-banner--bottom vf-banner--notice"
data-vf-js-banner
data-vf-js-banner-state="persistent"
data-vf-js-banner-extra-button="<a href='#'>Optional button</a><a target='_blank' href='#'>New tab button</a>">
<div class="vf-banner__content | vf-grid" data-vf-js-banner-notice-text>
<p class="vf-text vf-text-body--2">
A persistent banner <a class="vf-link" href="JavaScript:Void(0);">Privacy Notice</a> and <a class="vf-link" href="JavaScript:Void(0);">Terms Of Use</a>.
</p>
</div>
</div> -->
<!-- Blocking, dismissible banner -->
<!-- <div class="vf-banner vf-banner--blocking vf-banner--notice"
data-vf-js-banner
data-vf-js-banner-state="blocking" data-vf-js-banner-esc-close="y"
data-vf-js-banner-cookie-name="NaN"
data-vf-js-banner-cookie-version="NaN">
<div class="vf-banner__content | vf-grid" data-vf-js-banner-notice-text>
<div class="vf-box">
<h2 class="vf-text vf-text-heading-2">A blocking banner</h2>
<p class="vf-text vf-text-body--3">This might have a richer layout. Note, this implementation is not yet feature complete.</p>
</div>
</div>
</div> -->
<!-- programmatic banner -->
<!-- <div class="vf-banner vf-banner--fixed vf-banner--bottom vf-banner--notice"
data-vf-js-banner-id="32423"
></div> -->
Depending on your environment you'll want to use render or include. As a rule of thumb: server-side use include, precompiled browser use render. If you're using vf-eleventy you should use include.
includeYou'll need to pass a context object from your code or Yaml file (example), as well as the path to the Nunjucks template. Nunjucks' include is an abstraction of render and provides some additional portability.
{% set context fromYourYamlFile %}
- or -
{% set context = {
"component-type": "container",
"data-service-id": "MyService",
"data-protection-version": 0.1,
"banner__text": "I agree, dismiss this banner",
"banner__link": null,
"banner__inline_href": "JavaScript:Void(0);",
"alert_icon_text": "dismiss"
}
%}
{% include "../path_to/vf-banner/vf-banner.njk" %}
renderThis approach is best for bare-bones Nunjucks environments, such as precompiled templates with the Nunjucks slim runtime where include is not be available.
{% render '@vf-banner', {
"component-type": "container",
"data-service-id": "MyService",
"data-protection-version": 0.1,
"banner__text": "I agree, dismiss this banner",
"banner__link": null,
"banner__inline_href": "JavaScript:Void(0);",
"alert_icon_text": "dismiss"
} %}
<div class="vf-banner vf-banner--fixed vf-banner--top vf-banner--phase" data-vf-js-banner data-vf-js-banner-state="dismissible" data-vf-js-banner-button-text="Close notice" data-vf-js-banner-button-theme="primary">
<div class="vf-banner__content" data-vf-js-banner-text>
<span class="vf-badge vf-badge--primary">BETA</span>
<p class="vf-banner__text">This is the new EMBL.org <a href="JavaScript:Void(0);" class="vf-banner__link">Complete our quick survey</a> to help us make it better.</p>
</div>
</div>
This repository is distributed with npm. After installing npm, you can install primer-buttons with this command.
$ yarn add --dev @visual-framework/vf-banner
The style files included are written in Sass. If you're using a VF-core project, you can import it like this:
@import "@visual-framework/vf-banner/index.scss";
Make sure you import Sass requirements along with the modules. You can use a project boilerplate or the vf-sass-starter
--inline variant Nunjucks template file cleanup.vf-data-protection-banner__text -> banner__textvf-data-protection-banner__link -> banner__linkvf-banner--inline_href -> banner__inline_href--phase variant.set- style functions to cleaner versionvf-button--primary (if a specific button variant has been requested by vfJsBannerButtonTheme, it will still be used)v2.0.0 of the vf-design-tokens package or newerconsole.logvf-banner classvf-banner__content classvf-banner__content if parent has vf-u-fullbleed classvf-banner__button.vf-banner__link--alert and --warning bannersvf-banner--phase is on its way to deprecation, use vf-banner--info insteadvf-banner__textvf-text is deprecatedvf-text components inside--phase variant
File system location: components/vf-banner
Find an issue on this page? Propose a change or discuss it.