Button
نمای کلیimport { Button, ButtonGroup, CompactButton, FancyButton, LinkButton } from '@nili/ui';این همان صفحهی نمای کلیِ خود کتابخانه است که زنده رندر میشود. زبان یا تم را از هدر عوض کنید، همراهش میآید.
ظاهرها
چهار سبک بصری. filled حالت پیشفرض است؛ وقتی به وزن بصری کمتری نیاز دارید از stroke، lighter یا ghost استفاده کنید.
import { Button } from "@nili/ui"
export function Example() {
return (
<>
<Button appearance="filled">Filled</Button>
<Button appearance="stroke">Stroke</Button>
<Button appearance="lighter">Lighter</Button>
<Button appearance="ghost">Ghost</Button>
</>
)
}رنگها
primary، neutral، error و success. هر رنگ با هر ظاهری ترکیب میشود.
import { Button } from "@nili/ui"
export function Example() {
return (
<>
<Button color="primary">Primary</Button>
<Button color="neutral">Neutral</Button>
<Button color="error">Error</Button>
<Button color="success">Success</Button>
</>
)
}اندازهها
اندازهی md (۴۰ پیکسل) پیشفرض است. اندازههای کوچکتر همان مقیاس آیکون و تایپوگرافی را نگه میدارند.
import { Button } from "@nili/ui"
export function Example() {
return (
<>
<Button size="md">Medium</Button>
<Button size="sm">Small</Button>
<Button size="xs">X-Small</Button>
<Button size="2xs">2X-Small</Button>
</>
)
}همراه با آیکون
هر نود ریاکتی را میتوانید به startIcon یا endIcon بدهید. اندازه و فاصلهی آیکون خودکار تنظیم میشود.
import { Button, Icon } from "@nili/ui"
import { RiArrowLeftSLine, RiArrowRightSLine } from "@remixicon/react"
export function Example() {
return (
<Button
startIcon={<Icon icon={RiArrowLeftSLine} mirrored />}
endIcon={<Icon icon={RiArrowRightSLine} mirrored />}
>
Continue
</Button>
)
}فقط آیکون
دکمههای مربعی. همیشه با aria-label یک نام دسترسپذیر بدهید؛ یک آیکون تنها هیچ نامی ندارد.
import { Button, Icon } from "@nili/ui"
import { RiAddLine } from "@remixicon/react"
export function Example() {
return (
<Button iconOnly aria-label="Add" startIcon={<Icon icon={RiAddLine} />} />
)
}در حال بارگذاری و غیرفعال
حالت loading عرض اولیه را نگه میدارد تا چیدمان نپرد. حالت disabled واقعاً همان صفت disabled است.
import { Button } from "@nili/ui"
export function Example() {
return (
<>
<Button loading loadingLabel="Sending">Send</Button>
<Button disabled>Disabled</Button>
</>
)
}تمامعرض
برای فرمها و شیتهای موبایل مناسب است.
import { Button } from "@nili/ui"
export function Example() {
return <Button fullWidth>Continue</Button>
}دکمههای لینکی
کنشهایی با وزن متن که داخل نوشته مینشینند. با underline همیشه زیرخطدار میشوند، وگرنه فقط روی هاور زیرخط میگیرند.
import { LinkButton, Icon } from "@nili/ui"
import { RiArrowRightSLine } from "@remixicon/react"
export function Example() {
return (
<>
<LinkButton href="#" color="primary">Primary link</LinkButton>
<LinkButton href="#" color="gray">Gray link</LinkButton>
<LinkButton href="#" color="error" underline>
Underlined
</LinkButton>
<LinkButton
href="#"
color="primary"
endIcon={<Icon icon={RiArrowRightSLine} mirrored />}
>
With icon
</LinkButton>
</>
)
}دکمههای Fancy
گونهی برجسته، برای تنها کنش مهمِ یک صفحه. دستنگهدار مصرفش کنید؛ اگر سهتا باشد، هیچکدام دیگر ویژه نیست.
import { FancyButton, Icon } from "@nili/ui"
import { RiArrowRightSLine } from "@remixicon/react"
export function Example() {
return (
<>
<FancyButton color="primary">Primary</FancyButton>
<FancyButton color="neutral">Neutral</FancyButton>
<FancyButton color="basic">Basic</FancyButton>
<FancyButton
color="primary"
endIcon={<Icon icon={RiArrowRightSLine} mirrored />}
>
Continue
</FancyButton>
</>
)
}دکمههای فشرده
کنترلهای مربعی و فقطآیکون برای فضاهای تنگ: کنشهای ردیف جدول، ادورنمنت ورودی، نوار ابزار. همیشه aria-label بدهید.
import { CompactButton, Icon } from "@nili/ui"
import { RiCloseLine, RiSettings3Line, RiMore2Fill } from "@remixicon/react"
export function Example() {
return (
<>
<CompactButton appearance="stroke" aria-label="Close">
<Icon icon={RiCloseLine} />
</CompactButton>
<CompactButton appearance="ghost" aria-label="Settings">
<Icon icon={RiSettings3Line} />
</CompactButton>
<CompactButton appearance="error" aria-label="Delete">
<Icon icon={RiCloseLine} />
</CompactButton>
</>
)
}Button
extends Omit< ComponentPropsWithoutRef<'button'>, 'color' >
محورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| color | primary | neutral | error | success | basic | primary | Figma `🧩 Type` — Primary · Neutral · Error · Success. |
| appearance | filled | stroke | lighter | ghost | filled | |
| size | md | sm | xs | 2xs | md | |
| fullWidth | boolean | false | |
| iconOnly | boolean | false | Square icon-only button. Requires `aria-label` — a button whose only content is an SVG has no accessible name otherwise. |
بقیهی پراپها
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| children | ReactNode | — | |
| disabled | boolean | — | |
| required | boolean | — | |
| readOnly | boolean | — | |
| value | string | — | |
| defaultValue | string | — | |
| name | string | — | |
| aria-label | string | — | |
| startIcon | ReactNode | — | |
| endIcon | ReactNode | — | |
| loading | boolean | false | Shows a spinner and blocks interaction without collapsing the layout. |
| loadingLabel | string | — | Announced while `loading`, e.g. `'Sending'`. |
| asChild | boolean | false | Render the child element instead of a `<button>`, keeping every style and handler. Use for links: `<Button asChild><a href="…">…</a></Button>`. |
ButtonGroup
extends ComponentPropsWithoutRef<'div'>
محورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| orientation | horizontal | vertical | horizontal |
بقیهی پراپها
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| children* | ReactNode | — | |
| aria-label | string | — | |
| size | sm | xs | 2xs | sm | |
| role | toolbar | radiogroup | group | toolbar | `'toolbar'` (default) for a row of independent actions. Use `'radiogroup'` when the segments are mutually exclusive choices — the roles are read out differently, and only one of them promises "pick exactly one". |
| label | string | — |
ButtonGroupItem
extends Omit< ComponentPropsWithoutRef<'button'>, 'color' >
محورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| selected | boolean | false | |
| iconOnly | boolean | false | |
| size | sm | xs | 2xs | sm | Overrides the size inherited from the group. Rarely needed. |
| orientation | horizontal | vertical | horizontal |
بقیهی پراپها
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| children | ReactNode | — | |
| disabled | boolean | — | |
| required | boolean | — | |
| readOnly | boolean | — | |
| value | string | — | |
| defaultValue | string | — | |
| name | string | — | |
| aria-label | string | — | |
| startIcon | ReactNode | — | |
| endIcon | ReactNode | — |
CompactButton
extends Omit< ComponentPropsWithoutRef<'button'>, 'color' | 'children' >
محورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| appearance | stroke | ghost | white | error | inherit | stroke | |
| size | lg | md | lg | |
| fullRadius | boolean | false | Pill instead of a rounded square. |
بقیهی پراپها
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| children* | ReactNode | — | The glyph. Required — this control is always icon-only. |
| disabled | boolean | — | |
| required | boolean | — | |
| readOnly | boolean | — | |
| value | string | — | |
| defaultValue | string | — | |
| name | string | — | |
| aria-label* | string | — | Accessible name. Required, not optional: a button whose only content is an SVG has no accessible name at all, so the type system asks for one. |
FancyButton
extends Omit< ComponentPropsWithoutRef<'button'>, 'color' >
محورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| color | neutral | primary | error | success | basic | primary | Figma `🧩 Type` — Neutral · Primary · Error · Success · Basic. |
| size | md | sm | xs | md | Figma `📏 Size` — Medium (40) · Small (36) · X-Small (32). |
| fullWidth | boolean | false |
بقیهی پراپها
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| children | ReactNode | — | |
| disabled | boolean | — | |
| required | boolean | — | |
| readOnly | boolean | — | |
| value | string | — | |
| defaultValue | string | — | |
| name | string | — | |
| aria-label | string | — | |
| startIcon | ReactNode | — | |
| endIcon | ReactNode | — | |
| asChild | boolean | false |
LinkButton
extends Omit< ComponentPropsWithoutRef<'a'>, 'color' >
محورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| color | gray | black | primary | error | success | inherit | gray | |
| size | md | sm | md | |
| underline | boolean | false |
بقیهی پراپها
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| startIcon | ReactNode | — | |
| endIcon | ReactNode | — | |
| disabled | boolean | — | |
| asChild | boolean | false | Render the child element instead of an `<a>` — for router links. |