Sidebar
نمای کلیimport { Sidebar, SidebarCard, SidebarDot, SidebarFooter, SidebarGroup, SidebarHeader } from '@nili/ui';این همان صفحهی نمای کلیِ خود کتابخانه است که زنده رندر میشود. زبان یا تم را از هدر عوض کنید، همراهش میآید.
پنل
سربرگ، گروههایی از آیتمها، و یک پابرگ. خودش جمع میشود: collapsed را ندهید و پنل وضعیت خودش را نگه میدارد، و هر SidebarTrigger داخلش تایش میکند. سایدباری که برای جمعشدن نیاز دارد اپ یک useState بنویسد، همانی است که بیشتر اپها بدون قابلیت جمعشدن منتشرش میکنند.
import {
Sidebar, SidebarHeader, SidebarGroup, SidebarItem,
SidebarFooter, SidebarUser, SidebarTrigger, Icon,
} from "@nili/ui"
import { RiHome5Line, RiFolderLine } from "@remixicon/react"
export function Example() {
return (
<Sidebar label="Main">
<SidebarHeader
logo={<PlaceholderLogo company="apex-financial" size="sm" label="" />}
title="Apex Financial"
subtitle="Pro plan"
action={<SidebarTrigger />}
collapsedAction={<SidebarTrigger />}
/>
<SidebarGroup label="Main">
<SidebarItem icon={<Icon icon={RiHome5Line} />} href="#">Home</SidebarItem>
<SidebarItem icon={<Icon icon={RiFolderLine} />} href="#" active>
Projects
</SidebarItem>
</SidebarGroup>
<SidebarFooter>
<SidebarUser
avatar={<Avatar size="sm" name="Ada Lovelace" tone="blue" />}
name="Ada Lovelace"
email="ada@nili.design"
/>
</SidebarFooter>
</Sidebar>
)
}ریل
باز و جمعشده یک کامپوننتاند: هر ردیف همان ردیف است با برچسبی که تا عرض صفر محو شده، پس ردیفی که به یکی اضافه شود به هر دو اضافه میشود. برچسبها بهجای آنکه از DOM حذف شوند در آن میمانند — ریلی از آیکونهای بیبرچسب همان چیدمانی است که بیش از همه به نامهای دسترسپذیرش نیاز دارد.
import { Sidebar } from "@nili/ui"
export function Example() {
const [collapsed, setCollapsed] = useState(true)
return (
<Sidebar
collapsed={collapsed}
onCollapsedChange={setCollapsed}
label="Main"
>
…
</Sidebar>
)
}Sidebar
extends ComponentPropsWithoutRef<'nav'>
محورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| collapsed | boolean | false | The rail. One boolean rather than a second component: every row is the same row with its label faded out. |
بقیهی پراپها
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| label | string | — | Accessible name, e.g. "Main". A page usually has more than one `<nav>`, and "navigation, navigation, navigation" is not a landmark list. |
SidebarFooter
SidebarGroup
extends ComponentPropsWithoutRef<'div'>
بقیهی پراپها
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| label | string | — | Figma's "MAIN" / "FAVS" caption. Becomes a rule on the rail. |
SidebarGroupLabel
داخلیمحورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| collapsed | 'true' | 'false' | false |
SidebarHeader
extends Omit< ComponentPropsWithoutRef<'div'>, 'title' >
محورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| collapsed | 'true' | 'false' | false |
بقیهی پراپها
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| logo | ReactNode | — | The workspace mark — a `PlaceholderLogo`, an `Avatar`, an `<img>`. |
| title | ReactNode | — | |
| subtitle | ReactNode | — | |
| action | ReactNode | — | Figma's workspace switcher, on the trailing edge. Hidden on the rail. |
SidebarItem
extends Omit< ComponentPropsWithoutRef<'a'>, 'color' >
محورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| active | boolean | false | The current page. Draws the primary marker in the gutter. |
| collapsed | 'true' | 'false' | false |
بقیهی پراپها
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| children | ReactNode | — | |
| aria-label | string | — | |
| icon | ReactNode | — | |
| href | string | — | Makes it a link. Without it the row renders as a `<button>`. |
| shortcut | ReactNode | — | Figma's ⌘1 chip on a FAVS row. Replaces the trailing chevron. |
| trailing | ReactNode | — | Overrides the trailing chevron with anything else — a count, a badge. |
| disabled | boolean | false |
SidebarItemLabel
داخلیمحورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| collapsed | 'true' | 'false' | false |
SidebarItemTrailing
داخلیمحورهای واریانت — از تعریف cva کامپوننت
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| collapsed | 'true' | 'false' | false |
SidebarUser
extends ComponentPropsWithoutRef<'button'>
بقیهی پراپها
| پراپ | نوع | پیشفرض | توضیح |
|---|---|---|---|
| children | ReactNode | — | |
| disabled | boolean | — | |
| required | boolean | — | |
| readOnly | boolean | — | |
| value | string | — | |
| defaultValue | string | — | |
| name* | string | — | |
| aria-label | string | — | |
| avatar | ReactNode | — | |
| string | — | ||
| badge | ReactNode | — | The verified tick beside the name. |