Tooltips can be styled using CSS custom properties. For example, a tooltip may have
-
- A tabindex of 0.
-
This demo measures the time needed to render 10000 tooltip elements then toggle the first tooltip.
- -
- Tooltips can be anchored to the left:
-
- Tooltips can have content which wraps lines, but this is discouraged,
- because tooltips are meant to contain as little content as possible.
- When tooltips have lengthy content anchored to the left, it looks like this:
-
A tooltip may contain
- code.
-
- content slot.
- Slotted content must be phrasing content, so no <p>s.
-
+ Visibility is controlled only by the checkbox (show() /
+ hide()). Hover and focus do not open or close the tooltip.
+ Screen readers announce when the tooltip is shown, not when the target
+ is focused.
+
A tooltip may contain
+ code.
+
+ content slot.
+