Aller au contenu principal

Dialog Component

Description

The Dialog component is a modal dialog that appears over the main content. It supports customizable backdrop behavior, ESC key closing, and scroll options.

Styled Subcomponents

ComponentDescription
Dialog_TitleThe title of the dialog.
Dialog_ContentThe main content area of the dialog.
Dialog_ActionsA section for placing action buttons.

Props

PropTypeDefaultDescription
openbooleanfalseControls whether the dialog is visible.
onClose() => voidundefinedCallback function when the dialog is closed.
maxWidthstring"600px"The maximum width of the dialog.
disableBackdropClickbooleanfalsePrevents closing when clicking the backdrop.
closeOnEscbooleantrueAllows closing the dialog by pressing ESC.
scroll"paper" , "body""paper"Controls the scrolling behavior inside the dialog.

Example Usage

import { Dialog, Button, Dialog_Title, Dialog_Content, Dialog_Actions } from "@nomana-it/liberty-core"
import { useState } from "react";
import { t } from "i18next";
import { LYCancelIcon } from "@ly_styles/icons";

export const DialogExample = () => {
const [open, setOpen] = useState(false);

const handleClose = () => {
setOpen(false);
};

return (
<div>
<Button onClick={() => setOpen(true)}>Open Dialog</Button>
<Dialog open={open} onClose={handleClose} maxWidth="500px" closeOnEsc>
<Paper_Popup>
<Dialog_Title>Dialog Title</Dialog_Title>
<Dialog_Content>
This is a simple dialog content area.
</Dialog_Content>
<Dialog_Actions>
<Button variant="outlined" onClick={handleClose} startIcon={LYCancelIcon}>
{t('button.close')}
</Button>
</Dialog_Actions>
</Paper_Popup>
</Dialog>
</div>
);
};

🔗 GitHub Repository (Core): Liberty Core
🔗 GitHub Repository (Test Project): Liberty Test
📖 Live Documentation: Liberty Core Docs
💖 Sponsor & Support: Sponsor Liberty Core