Badge
عرض شاملimport { Badge, StatusBadge } from '@nili/ui';هذه صفحة العرض الشامل الخاصة بالمكتبة، معروضة حيّة. غيّر اللغة أو السمة من الأعلى وسَتتبعك.
المظاهر
أربع معالجات. اسمها appearance لا style — فـstyle خاصية React نفسها، وأخذها يجعل النمط المضمّن مستحيلًا.
import { Badge } from "@nili/ui"
export function Example() {
return (
<>
<Badge appearance="filled">Filled</Badge>
<Badge appearance="light">Light</Badge>
<Badge appearance="lighter">Lighter</Badge>
<Badge appearance="stroke">Stroke</Badge>
</>
)
}الألوان
عشرة ألوان تُدمج بحرّية مع أي مظهر. اللون زينة — ضع المعنى في النص.
import { Badge } from "@nili/ui"
export function Example() {
return (
<>
<Badge color="gray">Gray</Badge>
<Badge color="blue">Blue</Badge>
<Badge color="green">Green</Badge>
<Badge color="red">Red</Badge>
</>
)
}الأحجام
medium (20 بكسل) وsmall (16 بكسل).
import { Badge } from "@nili/ui"
export function Example() {
return (
<>
<Badge size="medium">Medium</Badge>
<Badge size="small">Small</Badge>
</>
)
}النقطة والأيقونات والأرقام
dot يرسم نقطة في المقدّمة؛ ويقبل startIcon وendIcon أي عنصر. والرقم المجرّد هو children فقط — لا توجد خاصية منفصلة للعدّ.
import { Badge, Icon } from "@nili/ui"
import { RiSparkling2Line, RiArrowUpLine } from "@remixicon/react"
export function Example() {
return (
<>
<Badge color="green" appearance="light" dot>
Active
</Badge>
<Badge color="purple" startIcon={<Icon icon={RiSparkling2Line} />}>
New
</Badge>
<Badge color="green" endIcon={<Icon icon={RiArrowUpLine} />}>
12%
</Badge>
<Badge color="red">2</Badge>
</>
)
}شارة الحالة
مكوّن منفصل، لأن اللون يتبع الحالة: لا يمكن أن تُعرض شارة «Completed» بالأحمر بالخطأ. stroke أو light، مع أيقونة أو نقطة.
import { StatusBadge } from "@nili/ui"
export function Example() {
return (
<>
<StatusBadge status="completed">Completed</StatusBadge>
<StatusBadge status="pending" appearance="light">Pending</StatusBadge>
<StatusBadge status="failed" dot>Failed</StatusBadge>
<StatusBadge status="disabled" icon={false}>Disabled</StatusBadge>
</>
)
}Badge
extends Omit< ComponentPropsWithoutRef<'span'>, 'color' | 'children' >
محاور التنويع — من تعريف cva للمكوّن
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| appearance | filled | light | lighter | stroke | filled | Visual treatment. |
| color | gray | red | blue | orange | green | yellow | purple | sky | pink | teal | gray | |
| size | medium | small | medium | |
| disabled | boolean | false |
باقي الخصائص
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| children | ReactNode | — | Badge content. Replaces the old `label` / `number` / `number_label` trio: a boolean flag plus two parallel content props meant three ways to say the same thing and one of them was always ignored. |
| aria-label | string | — | |
| dot | boolean | false | Renders a dot before the label. Mutually exclusive with `startIcon`. |
| startIcon | ReactNode | — | |
| endIcon | ReactNode | — |
BadgeDot
داخليمحاور التنويع — من تعريف cva للمكوّن
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| size | medium | small | medium |
BadgeDotSlot
داخليBadgeIcon
داخليمحاور التنويع — من تعريف cva للمكوّن
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| size | medium | small | medium |
StatusBadge
extends Omit< ComponentPropsWithoutRef<'span'>, 'children' >
باقي الخصائص
| الخاصيّة | النوع | الافتراضي | ملاحظات |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| status | disabled | completed | pending | failed | completed | |
| appearance | light | stroke | stroke | |
| dot | boolean | false | Leading status dot instead of the icon. Decorative — the label carries the meaning. |
| icon | boolean | ReactNode | true | Leading status glyph. `true` (default) shows the Figma icon for `status`, a node replaces it, `false` hides it. |