Modal
Genel görünümimport { Modal, StatusModal } from '@nili/ui';Bu, kütüphanenin kendi genel görünüm sayfası — canlı olarak render ediliyor. Üstten dili veya temayı değiştirin, o da değişir.
Temel
open ve onOpenChange ile denetlenir. Body’ye taşınır, açıkken odağı hapseder ve kapanışta odağı tetikleyiciye geri verir.
import { Modal, Button } from "@nili/ui"
export function Example() {
const [open, setOpen] = useState(false)
return (
<>
<Button onClick={() => setOpen(true)}>Open</Button>
<Modal
open={open}
onOpenChange={setOpen}
title="Invite a teammate"
description="They will get an email with a link to join."
closeLabel="Close"
footer={
<>
<Button appearance="stroke" onClick={() => setOpen(false)}>Cancel</Button>
<Button onClick={() => setOpen(false)}>Send invite</Button>
</>
}
>
<TextInput label={t('invite.email')} placeholder="hello@nili.design" />
</Modal>
</>
)
}Boyutlar
Dört panel genişliği. headerSize ayrıdır — Figma’nın Medium (80) ve Small (56) başlığı.
import { Modal } from "@nili/ui"
export function Example() {
return (
<>
<Modal size="sm" … />
<Modal size="md" … />
<Modal size="lg" … />
<Modal size="xl" … />
</>
)
}Başlık ve hizalama
icon serbest bir ön yuvadır ve status’a üstün gelir. Dikey bir alignment simgeyi, başlığı ve metni ortalar — bir onayın istediği biçim.
import { Modal, Icon } from "@nili/ui"
import { RiDeleteBinLine } from "@remixicon/react"
export function Example() {
return (
<Modal
open={open}
onOpenChange={setOpen}
alignment="vertical"
status="error"
icon={<Icon icon={RiDeleteBinLine} />}
title="Delete this project?"
description="This cannot be undone. Everything in it will be removed."
stretchFooter
footer={
<>
<Button appearance="stroke" onClick={close}>Cancel</Button>
<Button color="error" onClick={close}>Delete</Button>
</>
}
/>
)
}Durum kipi
Durumu sabitlenmiş aynı kip: KeyIcon’u ve rengini kendisi seçer; böylece bir “success” iletişim kutusu kırmızı gelemez.
import { StatusModal, Button } from "@nili/ui"
export function Example() {
return (
<StatusModal
open={open}
onOpenChange={setOpen}
status="success"
alignment="vertical"
title="Payment received"
description="We have emailed you a receipt."
stretchFooter
footer={<Button onClick={close}>Done</Button>}
/>
)
}Kapatmayı denetlemek
closeOnOutsideClick ve closeOnEscape varsayılan olarak açıktır. Kaydedilmemiş iş tutan bir iletişim kutusu için kapatın — ama o zaman kapatma düğmesini bırakın, yoksa çıkış yolu kalmaz.
import { Modal } from "@nili/ui"
export function Example() {
return (
<Modal
open={open}
onOpenChange={setOpen}
closeOnOutsideClick={false}
closeOnEscape={false}
showClose
closeLabel="Close"
title="Unsaved changes"
…
/>
)
}Modal
extends Omit< ComponentPropsWithoutRef<'div'>, 'title' | 'children' >
Diğer proplar
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| open* | boolean | — | |
| onOpenChange* | (open: boolean) => void | — | |
| title | ReactNode | — | |
| description | ReactNode | — | |
| icon | ReactNode | — | Figma header "Right Icon" — a free leading slot. Wins over `status`. |
| status | error | warning | success | info | — | Picks the default KeyIcon and its colour. |
| headerSize | sm | md | sm | Figma header Medium (80) / Small (56). |
| alignment | horizontal | vertical | horizontal | Figma Status Modal alignment. `vertical` centres icon, title and text. |
| size | xl | lg | md | sm | md | |
| footer | ReactNode | — | |
| stretchFooter | boolean | false | |
| showClose | boolean | true | |
| closeLabel | string | Close | |
| closeOnOutsideClick | boolean | true | |
| closeOnEscape | boolean | true | |
| container | HTMLElement | null | — |
ModalBody
dahiliVaryant eksenleri — bileşenin cva tanımından
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| size | sm | md | sm |
ModalFooter
dahiliVaryant eksenleri — bileşenin cva tanımından
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| stretch | 'true' | 'false' | false |
ModalHeader
dahiliVaryant eksenleri — bileşenin cva tanımından
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| size | sm | md | sm | |
| alignment | horizontal | vertical | horizontal |
ModalOverlay
dahiliModalPanel
dahiliVaryant eksenleri — bileşenin cva tanımından
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| size | sm | md | lg | xl | md |
StatusModal
extends Omit< ModalProps, 'alignment' | 'status' >
Diğer proplar
| Prop | Tip | Varsayılan | Notlar |
|---|---|---|---|
| status* | error | warning | success | info | — | |
| alignment | horizontal | vertical | vertical |