Skip to content

منو

Button

Triggers an action. Seven variants for visual hierarchy, several sizes and an accessible loading state.

import { Button } from "@kashi-ui/react";

Variants

Use only one primary button per section of the page. An important second action (such as “Contact sales” next to “Get started”) takes outline, and every other action takes secondary or tertiary.

<Button variant="primary">ذخیره</Button>
<Button variant="outline">تماس با فروش</Button>
<Button variant="secondary">پیش‌نمایش</Button>
<Button variant="tertiary">انصراف</Button>
<Button variant="link">اطلاعات بیشتر</Button>
<Button variant="danger">حذف</Button>
<Button variant="danger-secondary">بایگانی</Button>

Sizes

<Button variant="primary" size="sm">کوچک</Button>
<Button variant="primary">متوسط</Button>
<Button variant="primary" size="lg">بزرگ</Button>
<Button variant="primary" size="xl">خیلی بزرگ</Button>

With an icon

In RTL, iconStart sits on the right and iconEnd on the left. Mark directional icons such as arrows with data-k-mirror so they flip in RTL.

<Button variant="primary" iconStart={<PlusIcon />}>پروژهٔ جدید</Button>
<Button iconEnd={<ArrowIcon />}>ادامه</Button>
<Button iconOnly aria-label="جستجو"><SearchIcon /></Button>
<Button variant="danger-secondary" iconOnly aria-label="حذف"><TrashIcon /></Button>

States

<Button variant="primary" loading>پرداخت</Button>
<Button disabled>غیرفعال</Button>

With href the button becomes a real link (<a>). With as you can pass your router’s link component, such as as={Link} in Next.js.

دکمهٔ لینکیلینک با ظاهر دکمه
<Button variant="primary" shape="pill">کاملاً گرد</Button>
<Button shape="square">گوشهٔ کم</Button>
<Button size="xs">خیلی کوچک</Button>
<Button href="/docs" variant="link">دکمهٔ لینکی</Button>
<Button as={Link} href="/pricing">با Link در Next.js</Button>
New props
NameDescription, type and default
shape

Corner shape

Type: "default""pill""square"Default "default"

size

The xs size (28 px) was added

Type: "xs""sm""md""lg""xl"Default "md"

href / target / rel

Renders as a link; with disabled, href is removed and aria-disabled is set

Type: string

as

Any element or component

Type: ElementType

Props

Props
NameDescription, type and default
variant

Visual style and importance of the action; outline has a brand border, for the second action beside the main button

Type: "primary""secondary""outline""tertiary""link""danger""danger-secondary"Default "secondary"

size

Size; heights are 36, 40, 44 and 48 px

Type: "sm""md""lg""xl"Default "md"

loading

Shows a spinner; the button stays focusable but ignores clicks

Type: booleanDefault false

loadingLabel

Text announced by screen readers while loading

Type: stringDefault "در حال بارگذاری"

iconStart

Icon at the start of the text

Type: ReactNode

iconEnd

Icon at the end of the text

Type: ReactNode

iconOnly

Square icon-only button; aria-label is required

Type: booleanDefault false

block

Full width

Type: booleanDefault false

Other <button> props such as onClick, type and disabled are supported too. type defaults to "button" so forms are not submitted by accident.

CSS variables

CSS variables
VariableUsage and default
--k-btn-height-{sm,md,lg,xl}

Height of each size

Default 2.25rem to 3rem × density

--k-btn-padding-{sm,md,lg,xl}

Inner horizontal padding

Default 0.75rem to 1.25rem × density

--k-btn-radius

Corner radius

Default var(--k-radius-md)

--k-btn-font-weight

Text weight

Default 600

--k-btn-gap

Space between icon and text

Default var(--k-space-1_5)

Accessibility

  • While loading, aria-disabled is used instead of disabled so keyboard focus is not lost, and the text “در حال بارگذاری” (loading) is announced with role="status".
  • An iconOnly button without aria-label warns in development.
  • The minimum touch target is 24×24 px, and the focus ring stays visible in Windows high-contrast mode.
  • To navigate to another page, use a link (<a class="k-btn">), not a button.