2022-12-01 00:37:09 +00:00
+++
description = "Marker badges to display in your text"
title = "Badge"
+++
The `badge` shortcode displays little markers in your text with adjustable color, title and icon.
{{% badge %}}Important{{% /badge %}}
{{% badge style="primary" title="Version" %}}6.6.6{{% /badge %}}
2022-12-02 17:31:54 +00:00
{{% badge style="red" icon="angle-double-up" %}}Captain{{% /badge %}}
2023-01-23 21:35:43 +00:00
{{% badge style="info" %}}New{{% /badge %}}
2024-04-04 18:02:54 +00:00
{{% badge color="fuchsia" icon="fa-fw fab fa-hackerrank" %}}Awesome{{% /badge %}}
2022-12-01 00:37:09 +00:00
## Usage
While the examples are using shortcodes with named parameter you are free to also call this shortcode from your own partials.
2023-07-27 15:02:13 +00:00
{{< tabs groupid = "shortcode-parameter" > }}
2023-06-05 21:20:37 +00:00
{{% tab title="shortcode" %}}
2022-12-01 00:37:09 +00:00
````go
{{%/* badge %}}Important{{% /badge */%}}
{{%/* badge style="primary" title="Version" %}}6.6.6{{% /badge */%}}
2022-12-02 17:31:54 +00:00
{{%/* badge style="red" icon="angle-double-up" %}}Captain{{% /badge */%}}
2023-01-23 21:35:43 +00:00
{{%/* badge style="info" %}}New{{% /badge */%}}
2024-04-04 18:02:54 +00:00
{{%/* badge color="fuchsia" icon="fa-fw fab fa-hackerrank" %}}Awesome{{% /badge */%}}
2022-12-01 00:37:09 +00:00
````
{{% /tab %}}
2023-06-05 21:20:37 +00:00
{{% tab title="partial" %}}
2022-12-01 00:37:09 +00:00
````go
{{ partial "shortcodes/badge.html" (dict
2023-07-27 14:14:55 +00:00
"page" .
2022-12-01 00:37:09 +00:00
"content" "Important"
)}}
{{ partial "shortcodes/badge.html" (dict
2023-07-27 14:14:55 +00:00
"page" .
2022-12-01 00:37:09 +00:00
"style" "primary"
"title" "Version"
"content" "6.6.6"
)}}
{{ partial "shortcodes/badge.html" (dict
2023-07-27 14:14:55 +00:00
"page" .
2022-12-01 00:37:09 +00:00
"style" "red"
2023-07-27 14:14:55 +00:00
"icon" "angle-double-up"
2022-12-01 00:37:09 +00:00
"content" "Captain"
)}}
{{ partial "shortcodes/badge.html" (dict
2023-07-27 14:14:55 +00:00
"page" .
2022-12-01 00:37:09 +00:00
"style" "info"
2023-01-23 21:35:43 +00:00
"content" "New"
)}}
{{ partial "shortcodes/badge.html" (dict
2023-07-27 14:14:55 +00:00
"page" .
2023-01-23 21:35:43 +00:00
"color" "fuchsia"
2023-07-27 14:14:55 +00:00
"icon" "fab fa-hackerrank"
2022-12-01 00:37:09 +00:00
"content" "Awesome"
)}}
````
{{% /tab %}}
{{< / tabs > }}
### Parameter
| Name | Default | Notes |
2023-07-27 14:07:01 +00:00
|-----------------------|-----------------|-------------|
2024-09-12 09:16:53 +00:00
| **style** | `default` | The style scheme used for the badge.< br >< br > - by severity: `caution` , `important` , `info` , `note` , `tip` , `warning` < br > - by brand color: `primary` , `secondary` , `accent` < br > - by color: `blue` , `cyan` , `green` , `grey` , `magenta` , `orange` , `red` < br > - by special color: `default` , `transparent` , `code` < br >< br > You can also [define your own styles ](shortcodes/notice#configuration ). |
2023-01-23 21:35:43 +00:00
| **color** | see notes | The [CSS color value ](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value ) to be used. If not set, the chosen color depends on the **style** . Any given value will overwrite the default.< br >< br > - for severity styles: a nice matching color for the severity< br > - for all other styles: the corresponding color |
| **title** | see notes | Arbitrary text for the badge title. Depending on the **style** there may be a default title. Any given value will overwrite the default.< br >< br > - for severity styles: the matching title for the severity< br > - for all other styles: _<empty>_ < br >< br > If you want no title for a severity style, you have to set this parameter to `" "` (a non empty string filled with spaces) |
2023-10-24 20:49:34 +00:00
| **icon** | see notes | [Font Awesome icon name ](shortcodes/icon#finding-an-icon ) set to the left of the title. Depending on the **style** there may be a default icon. Any given value will overwrite the default.< br >< br > - for severity styles: a nice matching icon for the severity< br > - for all other styles: _<empty>_ < br >< br > If you want no icon for a severity style, you have to set this parameter to `" "` (a non empty string filled with spaces) |
2022-12-01 08:00:36 +00:00
| _**<content>**_ | _<empty>_ | Arbitrary text for the badge. |
2022-12-01 00:37:09 +00:00
## Examples
### Style
#### By Severity
````go
2024-08-13 10:48:25 +00:00
{{%/* badge style="caution" %}}Magenta{{% /badge */%}}
{{%/* badge style="important" %}}Cyan{{% /badge */%}}
{{%/* badge style="info" %}}Blue{{% /badge */%}}
{{%/* badge style="note" %}}Orange{{% /badge */%}}
{{%/* badge style="tip" %}}Green{{% /badge */%}}
{{%/* badge style="warning" %}}Red{{% /badge */%}}
2022-12-01 00:37:09 +00:00
````
2024-08-13 10:48:25 +00:00
{{% badge style="caution" %}}Magenta{{% /badge %}}
{{% badge style="important" %}}Cyan{{% /badge %}}
{{% badge style="info" %}}Blue{{% /badge %}}
{{% badge style="note" %}}Orange{{% /badge %}}
{{% badge style="tip" %}}Green{{% /badge %}}
{{% badge style="warning" %}}Red{{% /badge %}}
2022-12-01 00:37:09 +00:00
#### By Brand Colors
````go
{{%/* badge style="primary" icon="bullhorn" title="Announcement" %}}Mandatory{{% /badge */%}}
{{%/* badge style="secondary" icon="bullhorn" title="Announcement" %}}Optional{{% /badge */%}}
2023-01-23 23:14:10 +00:00
{{%/* badge style="accent" icon="bullhorn" title="Announcement" %}}Special{{% /badge */%}}
2022-12-01 00:37:09 +00:00
````
{{% badge style="primary" icon="bullhorn" title="Announcement" %}}Mandatory{{% /badge %}}
{{% badge style="secondary" icon="bullhorn" title="Announcement" %}}Optional{{% /badge %}}
2023-01-23 23:14:10 +00:00
{{% badge style="accent" icon="bullhorn" title="Announcement" %}}Special{{% /badge %}}
2022-12-01 00:37:09 +00:00
#### By Color
````go
{{%/* badge style="blue" icon="palette" title="Color" %}}Blue{{% /badge */%}}
2024-08-13 10:48:25 +00:00
{{%/* badge style="cyan" icon="palette" title="Color" %}}Cyan{{% /badge */%}}
2022-12-01 00:37:09 +00:00
{{%/* badge style="green" icon="palette" title="Color" %}}Green{{% /badge */%}}
{{%/* badge style="grey" icon="palette" title="Color" %}}Grey{{% /badge */%}}
2024-08-13 10:48:25 +00:00
{{%/* badge style="magenta" icon="palette" title="Color" %}}Magenta{{% /badge */%}}
2022-12-01 00:37:09 +00:00
{{%/* badge style="orange" icon="palette" title="Color" %}}Orange{{% /badge */%}}
{{%/* badge style="red" icon="palette" title="Color" %}}Red{{% /badge */%}}
````
{{% badge style="blue" icon="palette" title="Color" %}}Blue{{% /badge %}}
2024-08-13 10:48:25 +00:00
{{% badge style="cyan" icon="palette" title="Color" %}}Cyan{{% /badge %}}
2022-12-01 00:37:09 +00:00
{{% badge style="green" icon="palette" title="Color" %}}Green{{% /badge %}}
{{% badge style="grey" icon="palette" title="Color" %}}Grey{{% /badge %}}
2024-08-13 10:48:25 +00:00
{{% badge style="magenta" icon="palette" title="Color" %}}Magenta{{% /badge %}}
2022-12-01 00:37:09 +00:00
{{% badge style="orange" icon="palette" title="Color" %}}Orange{{% /badge %}}
{{% badge style="red" icon="palette" title="Color" %}}Red{{% /badge %}}
#### By Special Color
````go
{{%/* badge style="default" icon="palette" title="Color" %}}Default{{% /badge */%}}
{{%/* badge style="transparent" icon="palette" title="Color" %}}Transparent{{% /badge */%}}
````
{{% badge style="default" icon="palette" title="Color" %}}Default{{% /badge %}}
{{% badge style="transparent" icon="palette" title="Color" %}}Transparent{{% /badge %}}
### Variants
#### Without Icon and Title Text
````go
{{%/* badge %}}6.6.6{{% /badge */%}}
{{%/* badge style="info" icon=" " title=" " %}}Awesome{{% /badge */%}}
{{%/* badge style="red" %}}Captain{{% /badge */%}}
````
{{% badge %}}6.6.6{{% /badge %}}
{{% badge style="info" icon=" " title=" " %}}Awesome{{% /badge %}}
{{% badge style="red" %}}Captain{{% /badge %}}
#### Without Icon
````go
{{%/* badge title="Version" %}}6.6.6{{% /badge */%}}
{{%/* badge style="info" icon=" " %}}Awesome{{% /badge */%}}
{{%/* badge style="red" title="Rank" %}}Captain{{% /badge */%}}
````
{{% badge title="Version" %}}6.6.6{{% /badge %}}
{{% badge style="info" icon=" " %}}Awesome{{% /badge %}}
{{% badge style="red" title="Rank" %}}Captain{{% /badge %}}
#### Without Title Text
````go
{{%/* badge icon="star" %}}6.6.6{{% /badge */%}}
{{%/* badge style="info" title=" " %}}Awesome{{% /badge */%}}
2022-12-02 17:31:54 +00:00
{{%/* badge style="red" icon="angle-double-up" %}}Captain{{% /badge */%}}
2022-12-01 00:37:09 +00:00
````
{{% badge icon="star" %}}6.6.6{{% /badge %}}
{{% badge style="info" title=" " %}}Awesome{{% /badge %}}
2022-12-02 17:31:54 +00:00
{{% badge style="red" icon="angle-double-up" %}}Captain{{% /badge %}}
2022-12-01 00:37:09 +00:00
#### All Set
````go
{{%/* badge icon="star" title="Version" %}}6.6.6{{% /badge */%}}
{{%/* badge style="info" %}}Awesome{{% /badge */%}}
2022-12-02 17:31:54 +00:00
{{%/* badge style="red" icon="angle-double-up" title="Rank" %}}Captain{{% /badge */%}}
2022-12-01 00:37:09 +00:00
````
{{% badge icon="star" title="Version" %}}6.6.6{{% /badge %}}
{{% badge style="info" %}}Awesome{{% /badge %}}
2022-12-02 17:31:54 +00:00
{{% badge style="red" icon="angle-double-up" title="Rank" %}}Captain{{% /badge %}}
2022-12-01 00:37:09 +00:00
#### Override for Severity
````go
{{%/* badge style="info" icon="rocket" title="Feature" %}}Awesome{{% /badge */%}}
````
{{% badge style="info" icon="rocket" title="Feature" %}}Awesome{{% /badge %}}
### Other
2023-03-14 20:48:18 +00:00
#### With User-Defined Color, Font Awesome Brand Icon and Markdown Title and Content
2023-01-23 21:35:43 +00:00
````go
2024-04-04 18:02:54 +00:00
{{%/* badge color="fuchsia" icon="fa-fw fab fa-hackerrank" title="**Font**" %}}**Awesome**{{% /badge */%}}
2023-01-23 21:35:43 +00:00
````
2024-04-04 18:02:54 +00:00
{{% badge color="fuchsia" icon="fa-fw fab fa-hackerrank" title="**Font**" %}}**Awesome**{{% /badge %}}
2023-01-23 21:35:43 +00:00
2022-12-02 17:31:54 +00:00
#### With Icon Content
2023-10-24 20:49:34 +00:00
You can combine the badge with the [`icon` shortcode ](shortcodes/icon ) to create even more stunning visuals.
2022-12-02 17:31:54 +00:00
In this case you need to declare `{{</* badge */>}}` instead of `{{%/* badge */%}}` . Note, that in this case it is not possible to put markdown in the content.
````go
2022-12-02 18:26:49 +00:00
{{< /* badge style="primary" icon="angle-double-up" >}}{{% icon skull-crossbones %}}{{< /badge */>}}
{{< /* badge style="primary" icon="angle-double-up" >}}{{% icon skull-crossbones %}} Pirate{{< /badge */>}}
{{< /* badge style="primary" title="Rank" >}}{{% icon skull-crossbones %}}{{< /badge */>}}
{{< /* badge style="primary" title="Rank" >}}{{% icon skull-crossbones %}} Pirate{{< /badge */>}}
{{< /* badge style="primary" icon="angle-double-up" title="Rank" >}}{{% icon skull-crossbones %}}{{< /badge */>}}
{{< /* badge style="primary" icon="angle-double-up" title="Rank" >}}{{% icon skull-crossbones %}} Pirate{{< /badge */>}}
2022-12-02 17:31:54 +00:00
````
2022-12-02 18:26:49 +00:00
{{< badge style = "primary" icon = "angle-double-up" > }}{{% icon skull-crossbones %}}{{< / badge > }}
{{< badge style = "primary" icon = "angle-double-up" > }}{{% icon skull-crossbones %}} Pirate{{< / badge > }}
{{< badge style = "primary" title = "Rank" > }}{{% icon skull-crossbones %}}{{< / badge > }}
{{< badge style = "primary" title = "Rank" > }}{{% icon skull-crossbones %}} Pirate{{< / badge > }}
{{< badge style = "primary" icon = "angle-double-up" title = "Rank" > }}{{% icon skull-crossbones %}}{{< / badge > }}
2022-12-02 17:31:54 +00:00
{{< badge style = "primary" icon = "angle-double-up" title = "Rank" > }}{{% icon skull-crossbones %}} Pirate{{< / badge > }}
2022-12-01 00:37:09 +00:00
#### Inside of Text
````go
Lorem ipsum dolor sit amet, graecis denique ei vel, at duo primis mandamus. {{%/* badge style="blue" icon="rocket" %}}Awesome{{% /badge */%}} Et legere ocurreret pri, animal tacimates complectitur ad cum. Cu eum inermis inimicus efficiendi. Labore officiis his ex, soluta officiis concludaturque ei qui, vide sensibus vim ad.
````
Lorem ipsum dolor sit amet, graecis denique ei vel, at duo primis mandamus. {{% badge style="blue" icon="rocket" %}}Awesome{{% /badge %}} Et legere ocurreret pri, animal tacimates complectitur ad cum. Cu eum inermis inimicus efficiendi. Labore officiis his ex, soluta officiis concludaturque ei qui, vide sensibus vim ad.