The vf-badge component is used to denote if a page, section, or link has a production state of alpha, beta or other information.
The vf-badge
accepts a single text item of content.
content type | variable | description |
---|---|---|
text | text |
The vf-badge
component can also be a link using <a class="vf-badge" href="">badge title</a>
.
variable | options | default |
---|---|---|
text | ||
badge_href | null | |
theme | 'primary' | |
style | 'outline' | |
override_class | ||
id |
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
.
include
You'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": "element",
"text": "alpha",
"theme": "primary"
}
%}
{% include "../path_to/vf-badge/vf-badge.njk" %}
render
This 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-badge', {
"component-type": "element",
"text": "alpha",
"theme": "primary"
} %}
<span class="vf-badge vf-badge--primary">alpha</span>
This repository is distributed with npm. After installing npm and yarn, you can install vf-profile
with this command.
$ yarn add --dev @visual-framework/vf-badge
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-badge/index.scss";
Make sure you import Sass requirements along with the modules. You can use a project boilerplate or the vf-sass-starter
vf-button
.vf-button
.vf-badge--primary
and vf-badge--outline
with vf-badge--secondary
.vf-badge--tertiary
.set-
style functions to cleaner version
File system location: components/vf-badge
Find an issue on this page? Propose a change or discuss it.