Skip to content

CSS: tooltip

.instui-tooltip — ฟองคำแนะนำ (tooltip) ด้วย CSS เมื่อโฮเวอร์หรือโฟกัส สามารถวางได้ทุกด้าน.

การสลับเป็นเพียว CSS (:hover/:focus-within) ดังนั้นฟองจะเข้าถึงผู้ใช้คีย์บอร์ดได้เฉพาะผ่านทริกเกอร์ที่รับโฟกัส; ต่างจาก popover มันไม่สามารถปิดได้ด้วยการคลิกหรือถูกกระตุ้นด้วยการคลิก.

Source: tooltip.css

TIP

การปรับปรุง JS — CSS ของคอมโพเนนต์นี้เรนเดอร์และทำงานได้ด้วยตัวเอง; จับคู่กับ @pantoken/interactions เพื่อเพิ่มพฤติกรรมเชิงโต้ตอบ ดู ตารางตัวปรับแต่งด้านล่าง.

การเข้าถึง

ชี้ทริกเกอร์ไปยังฟองด้วย aria-describedby และกำหนด role="tooltip" ให้กับฟอง.

การใช้งาน

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

ตัวอย่าง

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>

โครงสร้าง

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;

ตัวปรับแต่ง

ตัวปรับแต่งคำอธิบาย
.-icon-*แสดงไอคอนทริกเกอร์ถัดจากฟองคำแนะนำ.

ส่วนประกอบ

ส่วนคำอธิบาย
.tipฟองคำแนะนำ; -placement-* กำหนดด้านที่วาง.

โทเค็นที่ใช้

Tokenชนิดค่า
--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

ที่เกี่ยวข้อง

  • popover — พื้นผิวที่ใหญ่กว่า ถูกกระตุ้นด้วยการคลิกและยึดตำแหน่ง.
  • context-view — พื้นผิวที่เกี่ยวข้องซึ่งมีลูกศรชี้.