Badge
نمای کلیimport { Badge, StatusBadge } from '@nili/ui';این همان صفحهی نمای کلیِ خود کتابخانه است که زنده رندر میشود. زبان یا تم را از هدر عوض کنید، همراهش میآید.
ظاهرها
چهار پرداخت. نامش appearance است نه style — چون style پراپ خود ریاکت است و گرفتنش استایل اینلاین را غیرممکن میکرد.
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 (۲۰ پیکسل) و small (۱۶ پیکسل).
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. |