ข้ามไปยังเนื้อหา

กล่องข้อมูล

Popover

A button that opens a small box of extra information beside it, such as what a term means. It stays open until the person clicks elsewhere or presses Esc. For a word or two of help on hover, use Tooltip. For a decision, use Dialog.

ใช้อธิบายคำหรือตัวเลขเพิ่มเติมเมื่อผู้ใช้ต้องการ เช่น ยอดผูกพันคืออะไร กล่องเปิดค้างจนกดที่อื่นหรือกด Esc ถ้าเป็นคำอธิบายสั้น ๆ เมื่อชี้ ใช้ Tooltip ถ้าต้องตัดสินใจ ใช้ Dialog

import { Popover } from "@bsru/ui";

ตัวอย่าง

อธิบายคำ

label คือข้อความบนปุ่ม title และ body คือเนื้อหาในกล่อง

<Popover
  label="ยอดผูกพันคืออะไร"
  title="ยอดผูกพัน"
  body="เงินที่กันไว้สำหรับใบสั่งซื้อที่ออกแล้วแต่ยังไม่ได้เบิกจ่าย ยอดนี้ใช้ซ้ำไม่ได้จนกว่าจะเบิกจ่ายหรือยกเลิกใบสั่งซื้อ"
/>

props ทั้งหมด

ตัวอย่างด้านบนใช้ props เพียงบางตัว ตารางนี้แสดงทุกตัวที่คอมโพเนนต์รับ พร้อมค่าเริ่มต้นและค่าที่ใช้ได้

Popover props
ชื่อชนิดข้อมูลค่าเริ่มต้นคำอธิบาย
label* จำเป็นstring—The button's text, already in the screen language, such as What is a commitment?
title* จำเป็นstring—The box's heading.
body* จำเป็นstring—The explanation, a sentence or two.
iconLucideIconInfoShown before the button's text.
align"left" | "right""left"Which edge of the button the box lines up with.

ข้อควรปฏิบัติ

  • ปุ่มบอกว่าเปิดอยู่หรือไม่ด้วย aria-expanded กด Esc แล้วโฟกัสกลับที่ปุ่ม
  • เนื้อหาสั้น หนึ่งหรือสองประโยค ไม่ใส่ฟอร์มหรือปุ่มในกล่อง

ซอร์สโค้ด: ui/src/menu.tsx