Skip to content

CSS: modal

.instui-modal — Một bề mặt hộp thoại (hoạt động trên native <dialog>); các phần header/body/footer.

Xem các thành viên modal.header, modal.body, và modal.footer để biết các phần riêng lẻ.

Source: body.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

Mở native <dialog> với showModal() để có ngữ nghĩa modal và đóng bằng Esc, và đặt tên cho nó bằng aria-labelledby trỏ tới .header.

Sử dụng

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

Demo

Các ví dụ

html
<dialog class="instui-modal -size-sm" id="modal-sm">
  <div class="header"><strong>Small</strong></div>
  <div class="body"><code>-size-sm</code> — a narrow modal.</div>
  <div class="footer">
    <button class="instui-button">Close</button>
  </div>
</dialog>

Cấu trúc

text
.instui-modal
  modal.header (component)
  modal.body (component)
  modal.footer (component)
flowchart TD n0[".instui-modal"]:::cssdoc-root n1(["modal.header"]):::cssdoc-component n2(["modal.body"]):::cssdoc-component n3(["modal.footer"]):::cssdoc-component n0 --> n1 n0 --> n2 n0 --> n3 click n1 "/api/css/modal.header.md" click n2 "/api/css/modal.body.md" click n3 "/api/css/modal.footer.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;

Bộ sửa

Bộ sửaMô tả
.-blurLàm mờ phông nền phía sau modal.
.-color-inverseGiao diện nền tối (kết hợp với media body). @affects modal.header @affects modal.body @affects modal.footer — Thay đổi màu sắc từng phần để phù hợp giao diện nền tối.
.-density-compactThu hẹp khoảng đệm phần. @affects modal.header @affects modal.body @affects modal.footer — Thu hẹp padding của từng phần.
.-overflow-fitGiới hạn trong vùng nhìn thấy và cuộn body. @affects modal.body — Cuộn body khi modal bị giới hạn theo viewport.
.-size-autoKích thước theo nội dung.
.-size-fullscreenTừ mép tới mép.
.-size-largeMột modal rộng. Tên dài của -size-lg.
.-size-lgMột modal rộng.
.-size-smMột modal hẹp.
.-size-smallMột modal hẹp. Tên dài của -size-sm.

Phần tử giả

Phần tử giảMô tả
::backdropLàm mờ trang phía sau hộp thoại như một lớp che, và phủ sương bên dưới -blur.

Token tiêu thụ

TokenKiểuGiá trị
--instui-component-mask-background-color<color>LightDarklight-dark(rgba(255,255,255,0.75), rgba(28,34,43,0.75))
--instui-component-modal-auto-min-width<length>16em
--instui-component-modal-background-color<color>LightDarklight-dark(#ffffff, #171B21)
--instui-component-modal-border-color<color>LightDarklight-dark(#E8EAEC, #334450)
--instui-component-modal-border-radius<length>1rem
--instui-component-modal-border-width<length>0.0625rem
--instui-component-modal-font-family[ <font-family-name> | <generic-font-family> ]#Atkinson Hyperlegible Next, "Helvetica Neue", Helvetica, Arial, sans-serif
--instui-component-modal-inverse-background-color<color>LightDarklight-dark(#273540, #1C222B)
--instui-component-modal-inverse-border-color<color>#334450
--instui-component-modal-inverse-text-color<color>#ffffff
--instui-component-modal-large-max-width<length>62em
--instui-component-modal-medium-max-width<length>48em
--instui-component-modal-small-max-width<length>30em
--instui-component-modal-text-color<color>LightDarklight-dark(#273540, #F2F4F5)
--instui-elevation-topmostnone | <shadow>#
--instui-spacing-space-xl<length>1.5rem

Hỗ trợ trình duyệt

  • Định kiểu một native <dialog> và ::backdrop của nó; việc render lớp trên cùng và kiểu backdrop cần trình duyệt hỗ trợ phần tử dialog.

Các thành phần phụ

Liên quan

  • tray — Tray là cùng mẫu overlay có thể đóng, neo vào mép màn hình.