JGuang

侧边导航

SideBar · Ant Design Mobile

交互预览
npm install antd-mobile@5.43.0

侧边导航 SideBar

垂直展示导航栏。

安装

npm install antd-mobile@5.43.0

antd-mobile 是移动网页组件库,不是 React Native 或小程序组件。React 19 项目需在入口用 unstableSetRender 注册 createRoot,否则 Toast、Dialog 等命令式 API 无法渲染;深色模式通过 <html data-prefers-color-scheme="dark"> 切换。

示例来自 Ant Design Mobile 官方仓库(MIT),固定在 npm 5.43.0 对应的提交;示例中的 DemoBlock 等展示辅助组件由 JGuang 重写,不属于 antd-mobile 的 API。

垂直展示导航栏。

何时使用

需要用户快速导航至某一项内容集合,并可以在多个内容之间来回切换。

示例

属性

属性说明类型默认值
activeKey当前激活 item 的 keystring | null-
defaultActiveKey初始化选中 item 的 key,如果没有设置 activeKeystring | null第一个 item 的 key
onChange切换面板的回调(key: string) => void-

CSS 变量

属性说明默认值
--background-color背景颜色#f5f5f5
--height侧边导航高度100%
--item-border-radius当前激活item的圆角8px
--width侧边导航宽度105px

SideBar.Item

属性

属性说明类型默认值
badge徽标BadgeProps['content']-
disabled是否禁用booleanfalse
key对应 activeKeystring-
title显示内容ReactNode-