badges.md 3.0 KB
Newer Older
C
chomik 已提交
1 2
---
title: Badges
C
chomik 已提交
3
menu: docs.badges
M
Martyna 已提交
4
description: Badges are small count and labeling components, which are used to add extra information to an interface element. You can use them to draw users' attention to a new element, notify about unread messages or provide any kind of additional info.
C
codecalm 已提交
5
bootstrap-link: components/badge/
C
chomik 已提交
6 7
---

C
codecalm 已提交
8

C
codecalm 已提交
9
## Default markup
C
chomik 已提交
10

M
Martyna 已提交
11 12
The default badges are square and come in the basic set of colours. 

C
codecalm 已提交
13
{% capture code %}
C
chomik 已提交
14
{% for color in site.colors %}
D
Dawid Harat 已提交
15
<span class="badge bg-{{ color[0] }}">{{ color[0] }}</span>
C
chomik 已提交
16
{% endfor %}
C
codecalm 已提交
17
{% endcapture %}
C
codecalm 已提交
18
{% include example.html code=code centered=true %}
C
chomik 已提交
19

C
codecalm 已提交
20

C
codecalm 已提交
21
## Pill badges
C
chomik 已提交
22

M
Martyna 已提交
23
Use the `.bagde-pill` class if you want to create a badge with rounded corners. Its width will adjust to the label text.
D
Dawid Harat 已提交
24

C
codecalm 已提交
25
{% capture code %}
C
chomik 已提交
26
{% for color in site.colors %}
D
Dawid Harat 已提交
27
<span class="badge badge-pill bg-{{ color[0] }}">{{ forloop.index }}</span>
C
chomik 已提交
28
{% endfor %}
C
codecalm 已提交
29
{% endcapture %}
C
codecalm 已提交
30
{% include example.html code=code centered=true %}
C
chomik 已提交
31 32


M
Martyna 已提交
33
## Soft colour badges
C
chomik 已提交
34

M
Martyna 已提交
35
You can create a soft colour variant of a corresponding contextual badge variation, to make it look more subtle. Click [here]({% docs_url colors %}) to see the list of available colours and choose ones that best suit your design.
D
Dawid Harat 已提交
36

C
codecalm 已提交
37
{% capture code %}
C
chomik 已提交
38 39 40
{% for color in site.colors %}
<span class="badge bg-{{ color[0] }}-lt">{{ color[0] }}</span>
{% endfor %}
C
codecalm 已提交
41
{% endcapture %}
C
codecalm 已提交
42
{% include example.html code=code centered=true %}
C
chomik 已提交
43 44


C
codecalm 已提交
45
## Links
C
chomik 已提交
46

M
Martyna 已提交
47
Place the badge within an `<a>` element if you want it to perform the function of a link and make it clickable.
D
Dawid Harat 已提交
48

C
codecalm 已提交
49
{% capture code %}
C
chomik 已提交
50
{% for color in site.colors %}
C
codecalm 已提交
51
<a href="#" class="badge bg-{{ color[0] }}">{{ color[0] }}</a>
C
chomik 已提交
52
{% endfor %}
C
codecalm 已提交
53
{% endcapture %}
C
codecalm 已提交
54
{% include example.html code=code centered=true %}
C
chomik 已提交
55 56


C
codecalm 已提交
57
## Empty badges
C
chomik 已提交
58

M
Martyna 已提交
59
Leave the HTML element empty if you want to create badges without any text. Empty badges are particularly useful if you want to make an interface element more noticeable regardless of limited space.
D
Dawid Harat 已提交
60

C
codecalm 已提交
61
{% capture code %}
C
chomik 已提交
62
{% for color in site.colors %}
C
codecalm 已提交
63
<a href="#" class="badge bg-{{ color[0] }}"></a>
C
chomik 已提交
64
{% endfor %}
C
codecalm 已提交
65
{% endcapture %}
C
codecalm 已提交
66
{% include example.html code=code centered=true %}
67

C
codecalm 已提交
68

M
Martyna 已提交
69
### Badge add-ons
70

M
Martyna 已提交
71
Add the `.badge-addon` class to create an add-on that will customise your badge and make it more noticeable. You can use any colour variants and combine them as you see fit.
72

P
Paweł Kuna 已提交
73
{% capture code %}
74 75 76
{% include ui/badge.html text="task" color="green" addon="finished" %}
{% include ui/badge.html text="bundle" color="purple" addon="passing" %}
{% include ui/badge.html text="CSS gzip size" color="red-lt" addon="20.9kB" addon-color="red" %}
P
Paweł Kuna 已提交
77 78
{% endcapture %}
{% include example.html code=code %}
79

C
codecalm 已提交
80

81 82
### Badge avatars

M
Martyna 已提交
83
Create the `.badge-avatar` class to add an avatar that will make a badge more personalised.
84

P
Paweł Kuna 已提交
85
{% capture code %}
86 87 88 89 90
{% include ui/badge.html person-id=1 color="blue" %}
{% include ui/badge.html person-id=2 color="blue" %}
{% include ui/badge.html person-id=3 color="blue" %}
{% include ui/badge.html person-id=4 color="blue" %}
{% include ui/badge.html person-id=5 color="blue" %}
P
Paweł Kuna 已提交
91 92
{% endcapture %}
{% include example.html code=code %}