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 (40 بكسل) هو الافتراضي. تحتفظ الأحجام الأصغر بمقياس الأيقونة والخط نفسه.
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>
</>
)
}مع الأيقونات
مرِّر أي عنصر React إلى 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. |