Icon
نمای کلیimport { Icon, IconComponent } from '@nili/ui';این همان صفحهی نمای کلیِ خود کتابخانه است که زنده رندر میشود. زبان یا تم را از هدر عوض کنید، همراهش میآید.
پایه
خود کامپوننت آیکون را به icon بدهید، یا یک المان از پیش ساختهشده را بهعنوان فرزند. هر دو شکل هست چون جایی که از قبل یک المان در دست دارد نباید مجبور شود بازش کند.
import { Icon } from "@nili/ui"
import { RiSearchLine } from "@remixicon/react"
export function Example() {
return (
<>
{/* the component */}
<Icon icon={RiSearchLine} />
{/* or an element */}
<Icon>
<RiSearchLine />
</Icon>
</>
)
}اندازهها
size یک عدد پیکسل یا هر طول CSS را میگیرد. '1em' باعث میشود آیکون اندازهی فونت اطرافش را دنبال کند — همان چیزی که برای آیکونِ داخل یک خط متن میخواهید.
Search
Search
Search
Search
import { Icon } from "@nili/ui"
import { RiSearchLine } from "@remixicon/react"
export function Example() {
return (
<>
<Icon icon={RiSearchLine} size={16} />
<Icon icon={RiSearchLine} size={24} />
<Icon icon={RiSearchLine} size={40} />
{/* follows the text around it */}
<p className="text-[20px]">
{t('sizes.search')} <Icon icon={RiSearchLine} size="1em" />
</p>
</>
)
}رنگ
آیکون خودش را با currentColor میکشد، پس رنگ را از هرچه داخلش نشسته ارث میبرد — به همین دلیل داخل Button یا Badge بدون هیچ پراپ رنگی کار میکند. بهجای راه فرارِ color، یک کلاس توکنِ text-* را ترجیح دهید.
import { Icon, Button, Badge } from "@nili/ui"
import { RiCheckLine } from "@remixicon/react"
export function Example() {
return (
<>
{/* inherits */}
<span className="text-success-base">
<Icon icon={RiCheckLine} />
</span>
{/* inside a control, with nothing to say */}
<Button startIcon={<Icon icon={RiCheckLine} />}>
{t('colour.approve')}
</Button>
<Badge color="green" startIcon={<Icon icon={RiCheckLine} />}>Done</Badge>
</>
)
}آینهکردن
mirrored آیکون را در حالت راستبهچپ افقی برمیگرداند. آن را روی آیکونهای جهتدار بگذارید — فلشها، شورونها، هواپیمای ارسال — و روی بقیه نه: ساعت یا ذرهبینِ آینهشده فقط غلط است، نه بومیشده.
import { Icon } from "@nili/ui"
import { RiArrowRightSLine, RiSearchLine } from "@remixicon/react"
export function Example() {
return (
<>
{/* directional — flips in Persian */}
<Icon icon={RiArrowRightSLine} mirrored />
{/* not directional — must not flip */}
<Icon icon={RiSearchLine} />
</>
)
}نامهای دسترسپذیر
آیکون بهطور پیشفرض aria-hidden است، چون تقریباً هر آیکونی کنار متنی نشسته که معنایش را میگوید — و آیکونی که برچسب را تکرار کند، صفحهخوان را وادار میکند دو بار بگویدش. label را فقط وقتی بدهید که خود آیکون تمام پیام است.
import { Icon } from "@nili/ui"
import { RiCheckLine } from "@remixicon/react"
export function Example() {
return (
<>
{/* decorative: the word "Approved" is right there */}
<span>
<Icon icon={RiCheckLine} /> {t('names.approved')}
</span>
{/* meaningful: nothing else says this row passed */}
<Icon icon={RiCheckLine} label={t('names.passed')} />
</>
)
}Icon
extends Omit< SVGProps<SVGSVGElement>, 'color' | 'children' | 'ref' >
بقیهی پراپها
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| icon | IconComponent | — | The icon component itself, e.g. `RiAddLine` from `@remixicon/react`. |
| children | ReactNode | — | Alternative to `icon`: pass an already-created element as a child. |
| size | number | string | 24 | Pixel size, or any CSS length. `'1em'` makes the icon track font size. |
| color | string | — | Overrides `currentColor`. Prefer a `text-*` token class instead. |
| label | string | — | Accessible name. Provide this ONLY when the icon carries meaning on its own; otherwise the icon stays `aria-hidden` and the adjacent text speaks. |
| mirrored | boolean | false | Flip horizontally in RTL. Set on directional glyphs (arrows, chevrons). |
IconRender
داخلیextends Omit< SVGProps<SVGSVGElement>, 'color' | 'children' | 'ref' >
بقیهی پراپها
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| color | string | — | |
| size | number | string | — | |
| children | never | — |