همهی کامپوننتها
Banner
نمای کلی۱۰ اکسپورت۶ محور واریانت۱۷ پراپ۴ فایل
import { Banner, BannerAction } from '@nili/ui';این همان صفحهی نمای کلیِ خود کتابخانه است که زنده رندر میشود. زبان یا تم را از هدر عوض کنید، همراهش میآید.
وضعیتها
همان پنج معنای Alert. بنر معمولاً از همان اولین رندر روی صفحه است، پس بهطور پیشفرض مؤدبانه اعلام میشود.
این یک بنر error است.
این یک بنر warning است.
این یک بنر success است.
این یک بنر info است.
این یک بنر feature است.
import { Banner } from "@nili/ui"
export function Example() {
return (
<>
<Banner status="error" title="Payment failed." />
<Banner status="warning" title={t('content.maintenance')} />
<Banner status="success" title={t('content.verified')} />
<Banner status="info" title="We updated our terms." />
<Banner status="feature" title={t('content.feature')} />
</>
)
}ظاهرها
چهار پرداخت، همراستا با Alert.
ظاهر: filled
ظاهر: light
ظاهر: lighter
ظاهر: stroke
import { Banner } from "@nili/ui"
export function Example() {
return (
<>
<Banner appearance="filled" status="info" title="Filled" />
<Banner appearance="light" status="info" title="Light" />
<Banner appearance="lighter" status="info" title="Lighter" />
<Banner appearance="stroke" status="info" title="Stroke" />
</>
)
}توضیح، کنش و بستن
description بعد از عنوان و با یک نقطه جدا میآید. بنر طبق طراحی فقط یک action درونخطی میگیرد؛ اگر دوتا لازم دارید، چیزی که میخواهید Alert است.
با توضیح و کنش
Scheduled maintenance tonight.بین ساعت ۰۲:۰۰ تا ۰۳:۰۰ به وقت UTC.
جزئیاتآیکون سفارشی
Smart filters are here.
یک نگاهی بیندازیدقابلبستن
Your account is verified.
import { Banner, Icon } from "@nili/ui"
import { RiSparkling2Line } from "@remixicon/react"
export function Example() {
const [open, setOpen] = useState(true)
if (!open) return null
return (
<Banner
status="feature"
appearance="light"
title="Smart filters are here."
description="Save a filter set and reuse it everywhere."
icon={<Icon icon={RiSparkling2Line} />}
action={{ label: "Take a look", href: "#" }}
dismissible
dismissLabel={t('close')}
onDismiss={() => setOpen(false)}
/>
)
}چسبان
sticky بنر را به بالای ویوپورت سنجاق میکند. برای اعلان در سطح صفحه درست است؛ برای بنری داخل یک کارت غلط.
You are viewing a read-only archive.
import { Banner } from "@nili/ui"
export function Example() {
return (
<Banner
sticky
status="info"
title={t('sticky.archive')}
/>
)
}Banner
extends Omit< ComponentPropsWithoutRef<'div'>, 'title' | 'children' >
محورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| status | error | warning | success | info | feature | info | |
| appearance | filled | light | lighter | stroke | filled | Named `appearance`, not `style`, so React's own `style` prop stays usable. |
بقیهی پراپها
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| title* | ReactNode | — | |
| description | ReactNode | — | Shown after the title, separated by a `∙`. |
| icon | boolean | ReactNode | true | `true` uses the default glyph for `status`; a node overrides it; `false` hides it. |
| action | BannerAction | — | Single inline link, per the Figma spec. |
| dismissible | boolean | false | |
| onDismiss | () => void | — | |
| dismissLabel | string | Dismiss | Accessible name for the close button. Required by `dismissible`. |
| sticky | boolean | false | Pins the banner to the top of the viewport. A page-level banner usually wants this; one rendered inside a card does not. |
| urgency | assertive | polite | off | polite | How assistive tech announces the banner. Defaults to `'polite'` — unlike Alert, a banner is almost always present on first paint rather than appearing in response to an action, so interrupting is wrong. Use `'assertive'` only when the banner appears mid-session. |
BannerAction
محورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| appearance | filled | light | lighter | stroke | filled |
BannerDismiss
داخلیمحورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| appearance | filled | light | lighter | stroke | filled |
BannerIcon
داخلیمحورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| status | error | warning | success | info | feature | info | |
| appearance | filled | light | lighter | stroke | filled |