Radio
نمای کلیimport { Radio, RadioCard, RadioGroup } from '@nili/ui';این همان صفحهی نمای کلیِ خود کتابخانه است که زنده رندر میشود. زبان یا تم را از هدر عوض کنید، همراهش میآید.
گروه
RadioGroup یک name را بین رادیوهایش مشترک میکند — و اگر ندهید خودش میسازد. بدون آن مرورگر آنها را یک گروه نمیبیند و کلیدهای جهت دیگر بینشان حرکت نمیکنند.
import { Radio, RadioGroup } from "@nili/ui"
export function Example() {
const [plan, setPlan] = useState("pro")
return (
<RadioGroup value={plan} onValueChange={setPlan} title={t('plan.label')}>
<Radio value="free" label={t('plan.free')} />
<Radio value="pro" label={t('plan.pro')} />
<Radio value="team" label={t('plan.team')} />
</RadioGroup>
)
}جهت
پیشفرض عمودی است. افقی برای دو سه گزینهٔ کوتاه خوب کار میکند — بیشتر که شود ردیف میشکند و گروهبندی دیگر خوانده نمیشود.
import { Radio, RadioGroup } from "@nili/ui"
export function Example() {
return (
<RadioGroup orientation="horizontal" defaultValue="monthly" label="Billing">
<Radio value="monthly" label={t('billing.monthly')} />
<Radio value="yearly" label={t('billing.yearly')} />
</RadioGroup>
)
}ردیف برچسب
همان چهار اسلات Checkbox: sublabel، badge، description و linkButton. labelPosition کنترل را به سمت دیگر میبرد.
import { Radio, RadioGroup, Badge, LinkButton } from "@nili/ui"
export function Example() {
return (
<RadioGroup defaultValue="pro" title={t('plan.label')}>
<Radio
value="pro"
label="Pro"
sublabel="(most popular)"
badge={<Badge size="small" color="blue" appearance="lighter">Save 20%</Badge>}
description="Everything in Free, plus unlimited projects."
linkButton={<LinkButton href="#" size="sm">Compare plans</LinkButton>}
/>
<Radio value="free" label="Free" description="One project, one seat." />
</RadioGroup>
)
}کارت رادیویی
رادیویی که بهشکل یک پنل انتخابشدنی رندر میشود — انتخاب پلن، روش پرداخت. شش Type فیگما همان یک اسلات startAdornment است: اگر enum بود ناسازگار میشدند و نوع هفتم یک انتشار تازهٔ کتابخانه میخواست.
import { RadioGroup, RadioCard, KeyIcon, Icon } from "@nili/ui"
import { RiBankCardLine, RiWallet3Line } from "@remixicon/react"
export function Example() {
const [method, setMethod] = useState("card")
return (
<RadioGroup value={method} onValueChange={setMethod} title="Payment method">
<RadioCard
value="card"
label="Card"
description="Visa, Mastercard or a local card."
startAdornment={
<KeyIcon size="md" color="blue"><Icon icon={RiBankCardLine} /></KeyIcon>
}
/>
<RadioCard
value="wallet"
label="Wallet"
sublabel="balance ۱۲۰٬۰۰۰"
startAdornment={
<KeyIcon size="md" color="green"><Icon icon={RiWallet3Line} /></KeyIcon>
}
/>
</RadioGroup>
)
}Radio
extends Omit< ComponentPropsWithoutRef<'input'>, 'type' | 'size' >
بقیهی پراپها
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| disabled | boolean | — | |
| required | boolean | — | |
| readOnly | boolean | — | |
| checked | boolean | — | |
| defaultChecked | boolean | — | |
| placeholder | string | — | |
| value | string | — | |
| defaultValue | string | — | |
| name | string | — | |
| maxLength | number | — | |
| autoComplete | string | — | |
| aria-label | string | — | |
| label | ReactNode | — | |
| sublabel | ReactNode | — | Muted text inline after the label — Figma's "Sublabel". |
| badge | ReactNode | — | Trailing slot on the label row — Figma's "Badge". |
| linkButton | ReactNode | — | Action under the description — Figma's "Link Button". |
| description | ReactNode | — | Secondary line under the label. Figma's "Description" toggle. |
| labelPosition | start | end | end | Which side the label sits on. Figma calls this "Flip". Logical, so `start` is left in English and right in Persian. |
| invalid | boolean | — | |
| rootClassName | string | — | Wrapper class. Use `className` for the control itself. |
RadioCard
extends Omit< ComponentPropsWithoutRef<'input'>, 'type' | 'size' >
محورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| invalid | 'true' | 'false' | false |
بقیهی پراپها
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| disabled | boolean | — | |
| required | boolean | — | |
| readOnly | boolean | — | |
| checked | boolean | — | |
| defaultChecked | boolean | — | |
| placeholder | string | — | |
| value | string | — | |
| defaultValue | string | — | |
| name | string | — | |
| maxLength | number | — | |
| autoComplete | string | — | |
| aria-label | string | — | |
| label | ReactNode | — | |
| sublabel | ReactNode | — | |
| description | ReactNode | — | |
| badge | ReactNode | — | |
| startAdornment | ReactNode | — | Leading slot — an icon, an `<Avatar>`, a brand mark, a card provider. |
| hideControl | boolean | false | Hides the radio dot, leaving the panel itself as the affordance. |
| rootClassName | string | — | Wrapper class. Use `className` for the control itself. |
RadioControl
داخلیمحورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| invalid | 'true' | 'false' | false |
RadioDescription
داخلیمحورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| disabled | 'true' | 'false' | false |
RadioGroup
extends Omit< ComponentPropsWithoutRef<'div'>, 'onChange' | 'defaultValue' | 'title' >
محورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| orientation | vertical | horizontal | vertical |
بقیهی پراپها
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| value | string | — | Selected value. Controlled. |
| defaultValue | string | ||
| onValueChange | (value: string) => void | — | |
| name | string | — | Shared `name`. Generated when omitted — without one the browser will not treat the inputs as a single group, and arrow keys stop moving between them. |
| disabled | boolean | — | Disables every radio in the group. |
| label | string | — | Accessible name for the group, e.g. `'Payment method'`. |
| title | ReactNode | — | Visible heading. Also names the group. |
| invalid | boolean | — | Marks the whole group invalid, e.g. an unanswered required question. |
RadioIndicator
داخلیمحورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| invalid | 'true' | 'false' | false |
RadioLabel
داخلیمحورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| disabled | 'true' | 'false' | false |
RadioRoot
داخلیمحورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| labelPosition | end | start | end | |
| align | center | start | center |