Skip to content

CSS: popover

.instui-popover — พื้นผิวยกระดับสำหรับ [popover] แบบเนทีฟ ที่วางตำแหน่งด้วยการจัดวาง anchor ของ CSS.

การจัดวางแบบ anchor รองรับเฉพาะ Chromium; ตัวป้องกัน @supports ทำให้ -placement-* เงียบและไม่ทำงานในเบราว์เซอร์อื่น ๆ และ UA จะจัดกึ่งกลาง popover บนเลเยอร์บนแทนที่จะเกิดความผิดพลาด.

Source: popover.css

การใช้งาน

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

ตัวอย่าง

html
<div class="instui-popover -placement-bottom" id="pop-1">
  <div class="instui-heading -level-h4">Share this page</div>
  <p class="instui-text -size-sm">A popover is a lightweight surface anchored to a trigger. This one uses the native <code>popover</code> attribute.</p>
</div>

โครงสร้าง

text
.instui-popover
  heading (component)
  text (component)
    code
flowchart TD n0[".instui-popover"]:::cssdoc-root n1(["heading"]):::cssdoc-component n2(["text"]):::cssdoc-component n3("code"):::cssdoc-part n0 --> n1 n2 --> n3 n0 --> n2 click n1 "/api/css/heading.md" click n2 "/api/css/text.md" classDef cssdoc-root stroke-width:1px; classDef cssdoc-part stroke-width:1px; classDef cssdoc-slot stroke-width:1px; classDef cssdoc-component stroke-width:1px;

ตัวปรับแต่ง

ตัวปรับแต่งคำอธิบาย
.-placement-bottomวางอยู่ด้านล่างของจุดยึด.
.-placement-endวางที่ปลาย (inline-end) ของจุดยึด.
.-placement-startวางที่จุดเริ่มต้น (inline-start) ของจุดยึด.
.-placement-topวางอยู่เหนือจุดยึด.

เงื่อนไข

ชนิดการค้นหาคำอธิบาย
supports(position-area: block-end)
supports(transition-behavior: allow-discrete)

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

Tokenชนิดค่า
--instui-border-width-sm<length>0.0625rem
--instui-color-background-elevated-surface-base<color>LightDarklight-dark(#ffffff, #171B21)
--instui-color-text-base<color>LightDarklight-dark(#273540, #F2F4F5)
--instui-component-popover-border-color<color>LightDarklight-dark(#8D959F, #6A7883)
--instui-component-popover-border-radius<length>0.75rem
--instui-elevation-abovenone | <shadow>#
--instui-spacing-space-sm<length>0.5rem

รองรับเบราว์เซอร์

  • ใช้การจัดวางแบบ anchor ของ CSS (position-anchor/position-area) และ API เนทีฟ [popover] ซึ่งทั้งคู่รองรับเฉพาะ Chromium ในปัจจุบัน; ตัวป้องกัน @supports ทำให้การวางตำแหน่งเป็นกลางในที่อื่น ๆ โดยที่ UA จะจัดกึ่งกลาง popover บนเลเยอร์บน

ส่วนประกอบย่อย

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

  • tooltip — tooltip เป็นพื้นผิวยึดติดขนาดเล็ก ที่ถูกเปิดด้วยการ hover หรือ focus.
  • context-view — Context view เป็นพื้นผิวยึดติดที่เกี่ยวข้องและมีตัวชี้.