كل المكوّنات
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 — فعلامة ✕ بلا اسم وصفي.
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} />
</>
)
}Alert
extends Omit< ComponentPropsWithoutRef<'div'>, 'title' | 'children' >
محاور التنويع — من تعريف cva للمكوّن
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| status | error | warning | success | info | feature | info | |
| appearance | filled | light | lighter | stroke | filled | Renamed from `style`, which shadowed React's `style` (`CSSProperties`). |
| size | x-small | small | large | small |
باقي الخصائص
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| title* | ReactNode | — | |
| description | ReactNode | — | |
| icon | boolean | ReactNode | true | `true` shows the default glyph for `status`; pass a node to override it; `false` hides it. The default glyph is decorative — the alert's meaning is carried by `role`, not by the picture. |
| actions | AlertAction[] | — | Up to two inline actions. Replaces the unused `linkButton`/`doubleLink`. |
| dismissible | boolean | false | Shows a close button. Requires `dismissLabel` for the accessible name. |
| onDismiss | () => void | — | |
| dismissLabel | string | Dismiss | Accessible name for the close button, e.g. `'Close'`. |
| urgency | assertive | polite | off | — | How assistive tech announces this alert. - `'assertive'` (default for `error`) interrupts the user immediately. - `'polite'` waits for a pause — right for success and info. - `'off'` for alerts rendered statically on page load, which should not be announced at all. |
AlertAction
AlertClose
داخليمحاور التنويع — من تعريف cva للمكوّن
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| size | x-small | small | large | small |
AlertIcon
داخليمحاور التنويع — من تعريف cva للمكوّن
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| status | error | warning | success | info | feature | info | |
| appearance | filled | light | lighter | stroke | filled | |
| size | x-small | small | large | small |