SettingsLayout
settings-layout左侧竖排分类导航配右侧卡片化设置分组,窄屏自动折叠到顶部
用法
基础分栏设置
左侧竖排分类导航 + 右侧卡片化分组列表,窄屏自动折叠为顶部导航。
通用设置
管理工作区基础偏好
偏好
- 自动保存编辑时自动同步草稿
- 紧凑模式压缩列表行距以展示更多数据
tsx
<SettingsLayout
items={[
{ value: "general", label: "通用" },
{ value: "notifications", label: "通知" },
{ value: "security", label: "安全" },
]}
>
<SettingsPanel value="general" title="通用设置" description="管理工作区基础偏好">
<SettingSection title="偏好">
<SettingRow title="自动保存" description="编辑时自动同步草稿" control={<Switch defaultChecked />} />
</SettingSection>
</SettingsPanel>
</SettingsLayout>何时用
系统配置、工作区设置、个人偏好等分组较多的中后台设置页面使用,提供左侧竖排分类导航(窄屏自动折叠到顶部)与右侧卡片化分组列表;普通整页壳体用 Layout,单行标签页切换用 Tabs。
导入
ts
import { SettingsLayout, SettingsPanel, SettingSection, SettingRow } from "@hulianui/ui"Props
SettingsLayout
| 名称 | 类型 | 默认 | 说明 |
|---|---|---|---|
items * | SettingsNavItem[] | - | 左侧分类导航项列表(含 value / label / icon / badge / disabled) |
value | string | - | 受控当前选中分类 |
defaultValue | string | 首个可用项 | 非受控初始选中分类 |
SettingsNavItem
| 名称 | 类型 | 默认 | 说明 |
|---|---|---|---|
value * | string | - | 唯一标识,对应 SettingsPanel.value |
label * | ReactNode | - | 导航标签文案 |
icon | ReactNode | - | 前置图标(由组件统一约束为 16px) |
badge | ReactNode | - | 尾部状态标记(如未保存圆点或计数标签) |
disabled | boolean | false | 是否禁用该导航项 |
SettingsPanel
| 名称 | 类型 | 默认 | 说明 |
|---|---|---|---|
value * | string | - | 与 SettingsNavItem.value 对应的唯一值 |
maxWidth | "sm" | "md" | "lg" | "full" | "lg" | 内容最大宽度档位 |
SettingSection
| 名称 | 类型 | 默认 | 说明 |
|---|---|---|---|
size | ListSize | "lg" | 行密度(透传 List.size) |
SettingRow
| 名称 | 类型 | 默认 | 说明 |
|---|---|---|---|
control | ReactNode | - | 右侧单个表单控件(如 Switch / Select / Input) |
actions | ReactNode[] | - | 右侧多个动作节点(与 control 二选一,优先使用 actions) |
Events
| 事件 | 类型 | 说明 |
|---|---|---|
SettingsLayout.onValueChange | (value: string) => void | 分类切换回调 |
Slots
| 插槽 | 类型 | 说明 |
|---|---|---|
SettingsLayout.navHeader | ReactNode | 左侧导航顶部扩展区(如搜索框) |
SettingsLayout.navFooter | ReactNode | 左侧导航底部固定区(如全局动作按钮) |
SettingsLayout.children | ReactNode | 右侧面板集合(放多个 SettingsPanel) |
SettingsPanel.title | ReactNode | 面板顶部主标题 |
SettingsPanel.description | ReactNode | 面板顶部说明文案 |
SettingsPanel.extra | ReactNode | 标题行右侧操作区(如保存按钮) |
SettingsPanel.children | ReactNode | 面板正文内容 |
SettingSection.title | ReactNode | 分组卡片上方的小标题 |
SettingSection.description | ReactNode | 分组标题下方可选补充说明 |
SettingSection.extra | ReactNode | 分组标题右侧附加内容 |
SettingSection.children | ReactNode | 分组内的 SettingRow 列表 |
SettingRow.title | ReactNode | 设置项标题(使用 children 自定义左侧内容时可省略) |
SettingRow.description | ReactNode | 设置项说明文案 |
SettingRow.children | ReactNode | 自定义左侧内容,提供时替代默认 title/description |
禁忌 / 坑
SettingsLayout内部基于垂直Tabs,受控模式下请同时传入value与onValueChange;不要与defaultValue混用。SettingRow同时传入actions和control时优先渲染actions。
相关
Playground
通用设置
管理工作区基础偏好
偏好
- 自动保存编辑时自动同步草稿
- 紧凑模式压缩列表行距以展示更多数据
<SettingsLayout items={items}>
<SettingsPanel value="general" maxWidth="lg" title="通用设置">
<SettingSection title="偏好">
<SettingRow title="自动保存" control={<Switch defaultChecked />} />
</SettingSection>
</SettingsPanel>
</SettingsLayout>