Skip to content

CSS: tooltip

.instui-tooltip — Một bong bóng tooltip CSS khi hover và focus, có thể đặt ở bất kỳ phía nào.

Việc chuyển trạng thái hoàn toàn bằng CSS (:hover/:focus-within), nên bong bóng chỉ tiếp cận người dùng bàn phím thông qua một trigger có thể nhận focus; không giống popover, nó không thể đóng được hoặc không được kích hoạt bằng click.

Source: tooltip.css

TIP

Nâng cao JS — CSS của component này tự render và hoạt động độc lập; ghép với @pantoken/interactions để thêm hành vi tương tác. Xem bảng modifier phía dưới.

Khả năng truy cập

Chỉ định trigger tới bong bóng bằng aria-describedby và gán cho bong bóng role="tooltip".

Sử dụng

css
@import "@pantoken/components/components.css";
@import "@pantoken/components/tooltip.css";

Các ví dụ

html
<span class="instui-tooltip" aria-describedby="tt-1">
  <span class="instui-icon -icon-info"></span>
  <span class="tip" id="tt-1" role="tooltip">Default placement is top</span>
</span>

Cấu trúc

text
.instui-tooltip
  [class*="-icon-"] (0..1)
  .tip
flowchart TD n0[".instui-tooltip"]:::cssdoc-root n1("[class*=&quot;-icon-&quot;]"):::cssdoc-part n2(".tip"):::cssdoc-part n0 -.->|0..1| n1 n0 --> n2 classDef cssdoc-root stroke-width:1px; classDef cssdoc-part stroke-width:1px; classDef cssdoc-slot stroke-width:1px; classDef cssdoc-component stroke-width:1px;

Bộ sửa

Bộ sửaMô tả
.-icon-*Khi hiển thị, đặt một biểu tượng glyph trigger cạnh bong bóng tooltip.

Phần

PhầnMô tả
.tipBong bóng; -placement-* xác định phía của nó.

Token tiêu thụ

TokenKiểuGiá trị
--instui-border-radius-sm<length>0.25rem
--instui-color-background-inverse<color>LightDarklight-dark(#334450, #F2F4F5)
--instui-color-text-inverse<color>LightDarklight-dark(#ffffff, #1C222B)
--instui-component-tooltip-font-family[ <font-family-name> | <generic-font-family> ]#Atkinson Hyperlegible Next, "Helvetica Neue", Helvetica, Arial, sans-serif
--instui-component-tooltip-font-size<length>0.875rem
--instui-component-tooltip-font-weight<integer>400
--instui-component-tooltip-padding<length>0.75rem
--instui-spacing-space-xs<length>0.25rem

Liên quan

  • popover — Bề mặt neo lớn hơn, được kích hoạt bằng click.
  • context-view — Một bề mặt neo liên quan có mũi tên.