Badge element

The vf-badge component is used to denote if a page, section, or link has a production state of alpha, beta or other information.

github location npm version


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>.

Nunjucks and yml options

Nunjucks and YML variables available

variable options default
badge_href null
theme 'primary'
style 'outline'


As of version 3.0.0-alpha.0 vf-badge has experimental Angular support. This package was generated with Angular version 15.2.0 and has been tested on application with Angular version 15.2.0.

  1. install yarn add @visual-framework/vf-badge
  2. import in your app.module
    import { VfBadgeAngularModule } from '@visual-framework/vf-badge/vf-badge.angular';
      imports: [VfBadgeAngularModule, YourOtherModules],
  3. can be used as
    <vf-badge [text]="'alpha'" [theme]="'primary'" [id]="'Badge1'"></vf-badge>
  4. add to your styles.scss
    @import '../node_modules/@visual-framework/vf-sass-config/index.scss';
    @import "../node_modules/@visual-framework/vf-badge/vf-badge.scss";
    you should also install vf-sass-starter for the styles


<vf-badge [text]="'alpha'" [theme]="'primary'" [id]="'Badge1'"></vf-badge>


As of version 3.0.0-alpha.1 vf-badge has experimental React support which has been tested on react version 18.2.0

  1. install yarn add @visual-framework/vf-badge
  2. import in the JS file wheree you want to include this component
    import VfBadge from '@visual-framework/vf-badge/vf-badge.react';
    Make sure you have the jsx support enabled with babel. Alternatively, you can also copy the vf-badge.react.js file from below to your react project and import as per the location.
  3. can be used as
    <VfBadge text="ALPHA" theme="primary" id="Badge1"/>
  4. add beloow to your CSS file
    @import '~@visual-framework/vf-sass-config/index.scss';
    @import '~@visual-framework/vf-badge/vf-badge.css';
    you should also install and import vf-sass-starter for the styles


<VfBadge text="ALPHA" theme="primary" id="Badge1"/>


Nunjucks syntax

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.

Using 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" %}

Using 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",
Angular syntax
<vf-badge [text]="'alpha'" [theme]="'primary'" [id]="'Badge1'"/>
React syntax
<VfBadge text="ALPHA" theme="primary" id="Badge1"/>
 <span class="vf-badge vf-badge--primary">alpha</span>


Installation info

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





  • Added : Angular syntax for different variants as compared to common syntax
  • Added : Experimental React support for Badge component


  • Added : Experimental Angular support for Badge


  • Correct "secondry" typo.


  • makes the badges match the naming convention of the vf-button.
  • makes the badges match the styling of the vf-button.
  • removes any old deprecated variants and tidies up the code.

Migration Instructions

  • If you were using the "Outline Primary" variant you should use the "Secondary" variant now.
  • This replaces the classes of vf-badge--primary and vf-badge--outline with vf-badge--secondary.
  • IF you were using the "Default" variant you should use the "Tertiary" variant now.
  • This adds the class vf-badge--tertiary.


  • deprecates secondary and tertiary variants
  • makes the default the grey (tertiary) colour


  • changes any set- style functions to cleaner version


  • README cleanup


  • makes theme variant naming and decisions consistent


  • adds if statement to allow for context data to pass through

1.0.0 (2019-12-17)

  • Initial stable release


File system location: components/vf-badge

Find an issue on this page? Propose a change or discuss it.