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>
)
}بطاقة اختيار
زر اختيار مرسوم كلوحة قابلة للاختيار — منتقي الخطط ووسائل الدفع. وأنواع فيجما الستة هي فتحة startAdornment واحدة: لو كانت قائمة ثابتة لتنافت، ولاحتاج النوع السابع إلى إصدار جديد.
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 |