nili/ui
همه‌ی کامپوننت‌ها

Alert

نمای کلی
۱۱ اکسپورت۷ محور واریانت۱۷ پراپ۴ فایل
import { Alert, AlertAction } from '@nili/ui';

این همان صفحه‌ی نمای کلیِ خود کتابخانه است که زنده رندر می‌شود. زبان یا تم را از هدر عوض کنید، همراهش می‌آید.

وضعیت‌ها

پنج معنا. error به‌طور پیش‌فرض قاطعانه اعلام می‌شود؛ بقیه منتظر یک مکث می‌مانند.

این یک هشدار error است.
این یک هشدار warning است.
این یک هشدار success است.
این یک هشدار info است.
این یک هشدار feature است.
import { Alert } from "@nili/ui"

export function Example() {
  return (
    <>
      <Alert status="error" title="Something went wrong." />
      <Alert status="warning" title="Your trial ends in 3 days." />
      <Alert status="success" title="Payment received." />
      <Alert status="info" title="A new version is available." />
      <Alert status="feature" title="Try the new dashboard." />
    </>
  )
}

ظاهرها

filled، light، lighter و stroke. filled بلندترین است؛ نگهش دارید برای چیزهایی که واقعاً باید کار کاربر را قطع کنند.

ظاهر: filled
ظاهر: light
ظاهر: lighter
ظاهر: stroke
import { Alert } from "@nili/ui"

export function Example() {
  return (
    <>
      <Alert appearance="filled" status="info" title="Filled" />
      <Alert appearance="light" status="info" title="Light" />
      <Alert appearance="lighter" status="info" title="Lighter" />
      <Alert appearance="stroke" status="info" title="Stroke" />
    </>
  )
}

اندازه‌ها

x-small یک خط است بدون فضای آیکون؛ large توضیح و کنش هم می‌گیرد.

x-small
تغییرات شما ذخیره شد.
small
تغییرات شما ذخیره شد.
large
تغییرات شما ذخیره شد.

حالا همه‌ی اعضای تیم آن‌ها را می‌بینند.

import { Alert } from "@nili/ui"

export function Example() {
  return (
    <>
      <Alert size="x-small" status="success" title="Saved." />
      <Alert size="small" status="success" title="Saved." />
      <Alert
        size="large"
        status="success"
        title="Saved."
        description="Your changes are live for everyone on the team."
      />
    </>
  )
}

کنش‌ها، آیکون‌ها و بستن

actions تا دو کنش درون‌خطی می‌گیرد. icon با true آیکون پیش‌فرض را می‌آورد، با یک نود جایگزینش می‌کند و با false حذفش می‌کند. dismissible به dismissLabel نیاز دارد — یک ✕ هیچ نام دسترس‌پذیری ندارد.

Your plan is almost full.

You have used 92% of your storage.

Introducing smart filters.
بدون هیچ آیکونی.
مرا ببندید.
import { Alert, Icon } from "@nili/ui"
import { RiSparkling2Line } from "@remixicon/react"

export function Example() {
  const [open, setOpen] = useState(true)

  return (
    <>
      <Alert
        status="warning"
        appearance="stroke"
        size="large"
        title={t('actions.planTitle')}
        description={t('actions.planBody')}
        actions={[
          { label: "Upgrade", href: "#" },
          { label: "Dismiss", onClick: () => setOpen(false) },
        ]}
        dismissible
        dismissLabel={t('close')}
        onDismiss={() => setOpen(false)}
      />

      {/* Custom icon */}
      <Alert
        status="feature"
        title={t('actions.feature')}
        icon={<Icon icon={RiSparkling2Line} />}
      />

      {/* No icon */}
      <Alert status="info" title="No icon." icon={false} />
    </>
  )
}