Chuyển tới nội dung chính
Phiên bản: 1.10.0

Implementation

Sử dụng để hiển thị nội dung quan trọng hoặc yêu cầu người dùng thực hiện một hành động cụ thể trước khi tiếp tục sử dụng tính năng của ứng dụng

Properties

ModalActions

NameTypeDefaultDescription
textstringText hiển thị của action
highLightbooleanNếu giá trị là true action sẽ có kiểu highlight
dangerbooleanNếu giá trị là true action sẽ có kiểu danger
onClickfunctionFunction sẽ được gọi khi click action
closebooleanAction sau khi click sẽ close modal
disabledbooleanDisable action
NameTypeDefaultDescriptionMinimum Version
maskbooleanHiển thị mask
afterClosefunctionFunction được gọi sau khi modal đóng
onClosefunctionFunction được gọi khhi modal đóng
maskClosablebooleanCó thể đóng modal khi click vào mask
visiblebooleanHiển thị modal
unmountOnClosebooleanfalseUnmount sau khi đóng modal1.6.0
titlestringTitle của modal
coverSrcstringsrc của cover image
modalStyleReact.CSSPropertiesStyle modal
maskStyleReact.CSSPropertiesStyle mask
modalClassNamestringModal class name
maskClassNamestringMask class name
widthstring | numberModal width
heightstring | numberModal height
descriptionstringModal description
actionsModalActionsModal actions list
actionsDividerbooleanHiển thị divider giữa các action
zIndexnumberGiá trị zindex của modal

Example

import React, { useState } from "react";
import { Page, Button, Text, Modal, Box } from "zmp-ui";

export default function HomePage(props) {
  const [modalVisible, setModalVisible] = useState(false);
  const [dialogVisible, setDialogVisible] = useState(false);
  const [vDialogVisible, setVDialogVisible] = useState(false);
  const [popupVisible, setPopupVisible] = useState(false);
  return (
    <Page className="section-container">
      <Text.Title size="small">Dialog & Modal</Text.Title>
      <Box mt={4}>
        <Button
          variant="secondary"
          fullWidth
          onClick={() => {
            setDialogVisible(true);
          }}
        >
          Info Dialog
        </Button>
      </Box>
      <Box mt={4}>
        <Button
          variant="secondary"
          fullWidth
          onClick={() => {
            setVDialogVisible(true);
          }}
        >
          Info Dialog Vertical Actions
        </Button>
      </Box>
      <Box mt={4}>
        <Button
          variant="secondary"
          fullWidth
          onClick={() => {
            setPopupVisible(true);
          }}
        >
          Custom Modal
        </Button>
      </Box>
      <Box mt={4}>
        <Button
          variant="secondary"
          fullWidth
          onClick={() => {
            setModalVisible(true);
          }}
        >
          Custom Modal With Cover
        </Button>
      </Box>
      <Modal
        visible={dialogVisible}
        title="This is the title"
        onClose={() => {
          setDialogVisible(false);
        }}
        actions={[
          {
            text: "Button",
          },
          {
            text: "Button",
            close: true,
            highLight: true,
          },
        ]}
        description="This is a very long message that can be displayed in 3 lines"
      />
      <Modal
        visible={vDialogVisible}
        title="This is the title"
        onClose={() => {
          setVDialogVisible(false);
        }}
        verticalActions
        actions={[
          {
            text: "Long Text Button",
          },
          {
            text: "Long Text Button",
            close: true,
            highLight: true,
          },
        ]}
        description="This is a very long message that can be displayed in 3 lines"
      />
      <Modal
        visible={popupVisible}
        title="This is the title"
        onClose={() => {
          setPopupVisible(false);
        }}
        verticalActions
        description="This is a very long message that can be displayed in 3 lines"
      >
        <Box p={6}>
          <Button
            onClick={() => {
              setPopupVisible(false);
            }}
            fullWidth
          >
            Xác nhận
          </Button>
        </Box>
      </Modal>
      <Modal
        visible={modalVisible}
        title="ZaUI 2.0 Modal"
        coverSrc={"https://images.unsplash.com/photo-1561336313-0bd5e0b27ec8"}
        onClose={() => {
          setModalVisible(false);
        }}
        zIndex={1200}
        actions={[
          {
            text: "Button",
          },
          {
            text: "Cancel",
            close: true,
            highLight: true,
          },
        ]}
        description="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged."
      />
    </Page>
  );
}