JGuang

SideBar

SideBar · Ant Design Mobile

Preview
npm install antd-mobile@5.43.0

SideBar

Display the navigation bar vertically.

Install

npm install antd-mobile@5.43.0

antd-mobile is for mobile web, not React Native or Mini Programs. React 19 projects must register createRoot with unstableSetRender at the entry, or imperative APIs such as Toast and Dialog cannot render. Switch dark mode with <html data-prefers-color-scheme="dark">.

Examples come from the official Ant Design Mobile repository (MIT) at the commit published as npm 5.43.0. Presentation helpers such as DemoBlock are JGuang rewrites, not antd-mobile APIs.

Display the navigation bar vertically.

When to Use

Users are required to quickly navigate to a collection of content and switch back and forth between multiple pieces of content.

Demos

Props

NameDescriptionTypeDefault
activeKeykey of currently active itemstring | null-
defaultActiveKeyThe initialized key of the selected item, if the activeKey is not setstring | nullkey of the 1st item
onChangeCallback when switching panel(key: string) => void-

CSS Variables

NameDescriptionDefault
--background-colorColor of background#f5f5f5
--heightthe height of the SideBar100%
--item-border-radiusthe border-radius of the currently active item8px
--widththe width of the SideBar105px

SideBar.Item

Props

NameDescriptionTypeDefault
badgeBadge of the itemBadgeProps['content']-
disabledShould the item be disabledbooleanfalse
keyCorresponding to activeKeystring-
titleTitle of the itemReactNode-