Badges are used to provide additional context to an item like tagging.
Default= ui.nfg :badge, body: 'Default'
<span class="badge badge-primary">Default</span>
There are many options for variants. We typically use the :primary and :secondary options.
Primary Secondary Success Warning Danger= ui.nfg :badge, :primary, body: 'Primary'
= ui.nfg :badge, :secondary, body: 'Secondary'
= ui.nfg :badge, :success, body: 'Success'
= ui.nfg :badge, :warning, body: 'Warning'
= ui.nfg :badge, :danger, body: 'Danger'
<span class="badge badge-primary">Primary</span><span class="badge badge-secondary">Secondary</span><span class="badge badge-success">Success</span><span class="badge badge-warning">Warning</span><span class="badge badge-danger">Danger</span>
By default, icons are placed to the left of any text inside a badge.
Icon on Left= ui.nfg :badge, body: 'Icon on Left', icon: 'rocket'
<span class="badge badge-primary"><i aria-hidden="true" class="fa fa-rocket mr-1"></i> Icon on Left</span>
Using just an icon requires not including the body trait.
= ui.nfg :badge, icon: 'pencil'
<span class="badge badge-primary"><i aria-hidden="true" class="fa fa-pencil"></i></span>
Badges have the option to be rounded similar to buttons. We currently don't use rounded badges within our UI.
Rounded= ui.nfg :badge, :pill, body: 'Rounded'
<span class="badge badge-primary badge-pill">Rounded</span>
Badges can also be links. Use the link to show related items that have the same badge.
Click Me= ui.nfg :badge, body: 'Click Me', href: '#'
<a class="badge badge-primary" href="#">Click Me</a>
The badge component has these avaiable traits.
Adds an ID to the badge.
id: 'my_id'
= ui.nfg :badge, id: 'my_id'
Adds a class to the badge.
class: 'my-class'
= ui.nfg :badge, class: 'my-class'
For addding a data-describe to any badge.
describe: 'test-data-describe'
= ui.nfg :badge, describe: 'test-data-describe'
Text for badge.
body: 'Default'
= ui.nfg :badge, body: 'Default'
Used for adding links to badges.
href: 'http://www.networkforgood.com'
= ui.nfg :badge, body: 'HREF', href: 'http:www.networkforgood.com/'
Icons placed to the left of the text (default side).
icon: 'rocket'
= ui.nfg :badge, body: 'Icon', icon: 'rocket'
Determines the theme of the badge.
:primary
:secondary
:success
:warning
:danger
:info
:light
:dark
= ui.nfg :badge, :success, body: 'Success'
Shows a tooltip on badge.
tooltip: 'This is my tooltip!'
= ui.nfg :badge, body: 'Hover for tooltip', tooltip: 'Hi there!'
Shows the badge in pill form.
pill: true
= ui.nfg :badge, :pill, body: 'Rounded (Pill)'
Condition to determine if the badge shows or not.
render_if: (1==1)
= ui.nfg :badge, body: 'Rendered', render_if: (1==1)
Condition to determine if the badge shows or not.
render_unless: (1==1)
= ui.nfg :badge, body: 'Not Rendered', render_unless: (1==1)