x
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<nav aria-label="With icons and counters" data-view-component="true" class="tabnav"> <ul data-view-component="true" class="tabnav-tabs"> <li data-view-component="true" class="d-inline-flex"> <a href="#1" aria-current="page" data-view-component="true" class="tabnav-tab"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-star"> <path d="M8 .25a.75.75 0 0 1 .673.418l1.882 3.815 4.21.612a.75.75 0 0 1 .416 1.279l-3.046 2.97.719 4.192a.751.751 0 0 1-1.088.791L8 12.347l-3.766 1.98a.75.75 0 0 1-1.088-.79l.72-4.194L.818 6.374a.75.75 0 0 1 .416-1.28l4.21-.611L7.327.668A.75.75 0 0 1 8 .25Zm0 2.445L6.615 5.5a.75.75 0 0 1-.564.41l-3.097.45 2.24 2.184a.75.75 0 0 1 .216.664l-.528 3.084 2.769-1.456a.75.75 0 0 1 .698 0l2.77 1.456-.53-3.084a.75.75 0 0 1 .216-.664l2.24-2.183-3.096-.45a.75.75 0 0 1-.564-.41L8 2.694Z"></path> </svg> <span data-view-component="true">Stars</span> <span title="10" data-view-component="true" class="Counter">10</span> </a></li> <li data-view-component="true" class="d-inline-flex"> <a href="#2" data-view-component="true" class="tabnav-tab"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-heart"> <path d="m8 14.25.345.666a.75.75 0 0 1-.69 0l-.008-.004-.018-.01a7.152 7.152 0 0 1-.31-.17 22.055 22.055 0 0 1-3.434-2.414C2.045 10.731 0 8.35 0 5.5 0 2.836 2.086 1 4.25 1 5.797 1 7.153 1.802 8 3.02 8.847 1.802 10.203 1 11.75 1 13.914 1 16 2.836 16 5.5c0 2.85-2.045 5.231-3.885 6.818a22.066 22.066 0 0 1-3.744 2.584l-.018.01-.006.003h-.002ZM4.25 2.5c-1.336 0-2.75 1.164-2.75 3 0 2.15 1.58 4.144 3.365 5.682A20.58 20.58 0 0 0 8 13.393a20.58 20.58 0 0 0 3.135-2.211C12.92 9.644 14.5 7.65 14.5 5.5c0-1.836-1.414-3-2.75-3-1.373 0-2.609.986-3.029 2.456a.749.749 0 0 1-1.442 0C6.859 3.486 5.623 2.5 4.25 2.5Z"></path> </svg> <span data-view-component="true">Sponsors</span> <span title="14" data-view-component="true" class="Counter">14</span> </a></li> <li data-view-component="true" class="d-inline-flex"> <a href="#3" data-view-component="true" class="tabnav-tab"> <svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-bookmark"> <path d="M3 2.75C3 1.784 3.784 1 4.75 1h6.5c.966 0 1.75.784 1.75 1.75v11.5a.75.75 0 0 1-1.227.579L8 11.722l-3.773 3.107A.751.751 0 0 1 3 14.25Zm1.75-.25a.25.25 0 0 0-.25.25v9.91l3.023-2.489a.75.75 0 0 1 .954 0l3.023 2.49V2.75a.25.25 0 0 0-.25-.25Z"></path> </svg> <span data-view-component="true">Bookmarks</span> <span title="7" data-view-component="true" class="Counter">7</span> </a></li> </ul></nav>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
render(Primer::Alpha::TabNav.new(label: "With icons and counters")) do |component| component.with_tab(href: "#1", selected: true) do |tab| tab.with_icon(icon: :star) tab.with_text { "Stars" } tab.with_counter(count: 10) end component.with_tab(href: "#2") do |tab| tab.with_icon(icon: :heart) tab.with_text { "Sponsors" } tab.with_counter(count: 14) end component.with_tab(href: "#3") do |tab| tab.with_icon(icon: :bookmark) tab.with_text { "Bookmarks" } tab.with_counter(count: 7) endend
No notes provided.
No params configured.
app/components/primer/alpha/tab_nav.css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/* tabnav *//* Outer wrapper */.tabnav { margin-top: 0; /* stylelint-disable-next-line primer/spacing */ margin-bottom: var(--stack-gap-normal); border-bottom: var(--borderWidth-thin) solid var(--borderColor-default);}.tabnav-tabs { display: flex; /* stylelint-disable-next-line primer/spacing */ margin-bottom: calc(var(--borderWidth-thin) * -1); overflow: hidden;}.tabnav-tab { display: inline-block; flex-shrink: 0; /* stylelint-disable-next-line primer/spacing */ padding: var(--base-size-8) var(--control-medium-paddingInline-spacious); font-size: var(--text-body-size-medium); /* stylelint-disable-next-line primer/typography */ line-height: 23px; color: var(--fgColor-muted); -webkit-text-decoration: none; text-decoration: none; background-color: transparent; border: var(--borderWidth-thin) solid transparent; border-bottom: 0; transition: color 0.2s cubic-bezier(0.3, 0, 0.5, 1);}.tabnav-tab.selected,.tabnav-tab[aria-selected='true'],.tabnav-tab[aria-current]:not([aria-current='false']) { color: var(--fgColor-default); background-color: var(--bgColor-default); /* cover bottom border */ border-color: var(--borderColor-default); border-radius: var(--borderRadius-medium) var(--borderRadius-medium) 0 0; }:is(.tabnav-tab.selected,.tabnav-tab[aria-selected='true'],.tabnav-tab[aria-current]:not([aria-current='false'])) .octicon { color: inherit; }.tabnav-tab:hover { color: var(--fgColor-default); -webkit-text-decoration: none; text-decoration: none; transition-duration: 0.1s; }.tabnav-tab:focus,.tabnav-tab:focus-visible { border-radius: var(--borderRadius-medium) var(--borderRadius-medium) 0 0 !important; outline-offset: -6px; }.tabnav-tab:active { color: var(--fgColor-muted); }.tabnav-tab .octicon { /* stylelint-disable-next-line primer/spacing */ margin-right: var(--control-small-gap); color: var(--fgColor-muted); }.tabnav-tab .Counter { /* stylelint-disable-next-line primer/spacing */ margin-left: var(--control-small-gap); color: inherit; }/* Tabnav extras**** Tabnav extras are non-tab elements that sit in the tabnav. Usually they're** inline text or links. */.tabnav-extra { display: inline-block; /* stylelint-disable-next-line primer/spacing */ padding-top: 10px; /* stylelint-disable-next-line primer/spacing */ margin-left: 10px; font-size: var(--text-body-size-small); color: var(--fgColor-muted);}.tabnav-extra > .octicon { margin-right: var(--base-size-2); }/* When tabnav-extra are anchors *//* stylelint-disable-next-line selector-no-qualifying-type, selector-max-type */a.tabnav-extra:hover { color: var(--fgColor-accent); -webkit-text-decoration: none; text-decoration: none;}/* Tabnav buttons**** For when there are multiple buttons, space them out appropriately. Requires** the buttons to be floated or inline-block. */.tabnav-btn { /* stylelint-disable-next-line primer/spacing */ margin-left: var(--controlStack-medium-gap-condensed);}