You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please note that the `.tooltipped` component is **deprecated**.
11
+
</Note>
9
12
10
-
Add tooltips built entirely in CSS to nearly any element.
11
-
12
-
13
+
Add tooltips built entirely in CSS to appropriate elements.
13
14
14
15
## Implementation and accessibility
15
16
16
17
Tooltips as a UI pattern should be our last resort for conveying information because it is hidden by default and often with zero or little visual indicator of its existence.
17
18
18
19
Before adding a tooltip, please consider: Is this information essential and necessary* Can the UI be made clearer? Can the information be shown on the page by default?
19
20
20
-
**Attention**: we use `aria-label` for tooltip contents, because it is crucial that they are accessible to screen reader users. However, `aria-label`**replaces** the text content of an element in screen readers, so only use `.tooltipped` on elements with no existing text content, or consider using `title` for supplemental information.
21
+
### Attention
21
22
22
-
**Note:** Tooltip classes will conflict with Octicon styles, and as such, must be applied to the parent element instead of the icon.
23
+
-**Never** use tooltips on static elements. They should only be used on interactive elements, because users cannot tab-focus into static elements, which may make the content inaccessible for keyboard-only users and screen readers.
24
+
- we use `aria-label` for tooltip contents, because it is crucial that they are accessible to screen reader users. However, `aria-label`**replaces** the text content of an element in screen readers, so only use `.tooltipped` on elements with no existing text content such as an icon-only button.
25
+
- Tooltip classes will conflict with Octicon styles, and as such, must be applied to the parent element instead of the icon.
23
26
24
27
## Tooltip direction
25
28
Specify the direction of a tooltip with north, south, east, and west directions:
26
29
27
30
```html live
28
31
<divclass="d-flex flex-justify-center pt-4">
29
-
<spanclass="tooltipped tooltipped-nw m-2 p-2 border"aria-label="This is the tooltip on the North West side.">
32
+
<buttontype="button"class="tooltipped tooltipped-nw m-2 p-2 border"aria-label="This is the tooltip on the North West side.">
30
33
.tooltipped-nw
31
-
</span>
32
-
<spanclass="tooltipped tooltipped-n m-2 p-2 border"aria-label="This is the tooltip on the North side.">
34
+
</button>
35
+
<buttontype="button"class="tooltipped tooltipped-n m-2 p-2 border"aria-label="This is the tooltip on the North side.">
33
36
.tooltipped-n
34
-
</span>
35
-
<spanclass="tooltipped tooltipped-ne m-2 p-2 border"aria-label="This is the tooltip on the North East side.">
37
+
</button>
38
+
<buttontype="button"class="tooltipped tooltipped-ne m-2 p-2 border"aria-label="This is the tooltip on the North East side.">
36
39
.tooltipped-ne
37
-
</span>
40
+
</button>
38
41
</div>
39
42
<divclass="d-flex flex-justify-center">
40
-
<spanclass="tooltipped tooltipped-w m-2 p-2 border"aria-label="This is the tooltip on the West side.">
43
+
<buttontype="button"class="tooltipped tooltipped-w m-2 p-2 border"aria-label="This is the tooltip on the West side.">
41
44
.tooltipped-w
42
-
</span>
43
-
<spanclass="tooltipped tooltipped-e m-2 p-2 border"aria-label="This is the tooltip on the East side.">
45
+
</button>
46
+
<buttontype="button"class="tooltipped tooltipped-e m-2 p-2 border"aria-label="This is the tooltip on the East side.">
44
47
.tooltipped-e
45
-
</span>
48
+
</button>
46
49
</div>
47
50
<divclass="d-flex flex-justify-center pb-4">
48
-
<spanclass="tooltipped tooltipped-sw m-2 p-2 border"aria-label="This is the tooltip on the South West side.">
51
+
<buttontype="button"class="tooltipped tooltipped-sw m-2 p-2 border"aria-label="This is the tooltip on the South West side.">
49
52
.tooltipped-sw
50
-
</span>
51
-
<spanclass="tooltipped tooltipped-s m-2 p-2 border"aria-label="This is the tooltip on the South side.">
53
+
</button>
54
+
<buttontype="button"class="tooltipped tooltipped-s m-2 p-2 border"aria-label="This is the tooltip on the South side.">
52
55
.tooltipped-s
53
-
</span>
54
-
<spanclass="tooltipped tooltipped-se m-2 p-2 border"aria-label="This is the tooltip on the South East side.">
56
+
</button>
57
+
<buttontype="button"class="tooltipped tooltipped-se m-2 p-2 border"aria-label="This is the tooltip on the South East side.">
55
58
.tooltipped-se
56
-
</span>
59
+
</button>
57
60
</div>
58
61
```
59
62
@@ -62,36 +65,36 @@ Align tooltips to the left or right of an element, combined with a directional c
62
65
63
66
```html live
64
67
<divclass="d-flex flex-justify-center pt-4">
65
-
<spanclass="tooltipped tooltipped-nw tooltipped-align-right-1 m-2 p-2 border"aria-label="Tooltipped NW and aligned right.">
68
+
<buttontype="button"class="tooltipped tooltipped-nw tooltipped-align-right-1 m-2 p-2 border"aria-label="Tooltipped NW and aligned right.">
66
69
.tooltipped-nw .tooltipped-align-right-1
67
-
</span>
68
-
<spanclass="tooltipped tooltipped-ne tooltipped-align-left-1 m-2 p-2 border"aria-label="Tooltipped NE and aligned left.">
70
+
</button>
71
+
<buttontype="button"class="tooltipped tooltipped-ne tooltipped-align-left-1 m-2 p-2 border"aria-label="Tooltipped NE and aligned left.">
69
72
.tooltipped-ne .tooltipped-align-left-1
70
-
</span>
73
+
</button>
71
74
</div>
72
75
<divclass="d-flex flex-justify-center">
73
-
<spanclass="tooltipped tooltipped-nw tooltipped-align-right-2 m-2 p-2 border"aria-label="Tooltipped NW and aligned right.">
76
+
<buttontype="button"class="tooltipped tooltipped-nw tooltipped-align-right-2 m-2 p-2 border"aria-label="Tooltipped NW and aligned right.">
74
77
.tooltipped-nw .tooltipped-align-right-2
75
-
</span>
76
-
<spanclass="tooltipped tooltipped-ne tooltipped-align-left-2 m-2 p-2 border"aria-label="Tooltipped NE and aligned left.">
78
+
</button>
79
+
<buttontype="button"class="tooltipped tooltipped-ne tooltipped-align-left-2 m-2 p-2 border"aria-label="Tooltipped NE and aligned left.">
77
80
.tooltipped-ne .tooltipped-align-left-2
78
-
</span>
81
+
</button>
79
82
</div>
80
83
<divclass="d-flex flex-justify-center">
81
-
<spanclass="tooltipped tooltipped-sw tooltipped-align-right-1 m-2 p-2 border"aria-label="Tooltipped SE and aligned right.">
84
+
<buttontype="button"class="tooltipped tooltipped-sw tooltipped-align-right-1 m-2 p-2 border"aria-label="Tooltipped SE and aligned right.">
82
85
.tooltipped-sw .tooltipped-align-right-1
83
-
</span>
84
-
<spanclass="tooltipped tooltipped-se tooltipped-align-left-1 m-2 p-2 border"aria-label="Tooltipped SW and aligned left.">
86
+
</button>
87
+
<buttontype="button"class="tooltipped tooltipped-se tooltipped-align-left-1 m-2 p-2 border"aria-label="Tooltipped SW and aligned left.">
85
88
.tooltipped-se .tooltipped-align-left-1
86
-
</span>
89
+
</button>
87
90
</div>
88
91
<divclass="d-flex flex-justify-center pb-4">
89
-
<spanclass="tooltipped tooltipped-sw tooltipped-align-right-2 m-2 p-2 border"aria-label="Tooltipped SE and aligned right.">
92
+
<buttontype="button"class="tooltipped tooltipped-sw tooltipped-align-right-2 m-2 p-2 border"aria-label="Tooltipped SE and aligned right.">
90
93
.tooltipped-sw .tooltipped-align-right-2
91
-
</span>
92
-
<spanclass="tooltipped tooltipped-se tooltipped-align-left-2 m-2 p-2 border"aria-label="Tooltipped SW and aligned left.">
94
+
</button>
95
+
<buttontype="button"class="tooltipped tooltipped-se tooltipped-align-left-2 m-2 p-2 border"aria-label="Tooltipped SW and aligned left.">
93
96
.tooltipped-se .tooltipped-align-left-2
94
-
</span>
97
+
</button>
95
98
</div>
96
99
```
97
100
@@ -101,9 +104,9 @@ Use `.tooltipped-multiline` when you have long content. This style has some limi
101
104
102
105
```html live
103
106
<divclass="d-flex flex-justify-center pt-6">
104
-
<spanclass="tooltipped tooltipped-n tooltipped-multiline m-2 p-2 border"aria-label="This is the tooltip with multiple lines. This is the tooltip with multiple lines.">
107
+
<buttontype="button"class="tooltipped tooltipped-n tooltipped-multiline m-2 p-2 border"aria-label="This is the tooltip with multiple lines. This is the tooltip with multiple lines.">
105
108
.tooltipped-multiline
106
-
</span>
109
+
</button>
107
110
</div>
108
111
```
109
112
@@ -113,8 +116,8 @@ By default the tooltips have a slight delay before appearing. This is to keep mu
113
116
114
117
```html live
115
118
<divclass="d-flex flex-justify-center pt-4">
116
-
<spanclass="tooltipped tooltipped-n tooltipped-no-delay m-2 p-2 border"aria-label="This is the tooltip on the no delay side.">
119
+
<buttontype="button"class="tooltipped tooltipped-n tooltipped-no-delay m-2 p-2 border"aria-label="This is the tooltip on the no delay side.">
0 commit comments