Skip to content
Lenso UI

Toolbar 工具栏

用于承载可交互控件的容器,并支持方向键导航。

用法

import { Toolbar } from '@lenso/ui';

此预览复用英文版适配,不代表中文源示例已完成本地实现。

"use client";export { Basic } from "./source";

Local adaptation source above. Derived from HeroUI v3.2.6 source.

示例

垂直方向

此预览复用英文版适配,不代表中文源示例已完成本地实现。

"use client";export { Vertical } from "./source";

Local adaptation source above. Derived from HeroUI v3.2.6 source.

组合模式

此预览复用英文版适配,不代表中文源示例已完成本地实现。

"use client";export { Attached } from "./source";

Local adaptation source above. Derived from HeroUI v3.2.6 source.

与 ButtonGroup 组合

此预览复用英文版适配,不代表中文源示例已完成本地实现。

"use client";export { WithButtonGroup } from "./source";

Local adaptation source above. Derived from HeroUI v3.2.6 source.

自定义样式

Tailwind CSS

此预览复用英文版适配,不代表中文源示例已完成本地实现。

"use client";export { CustomStyles } from "./source";

Local adaptation source above. Derived from HeroUI v3.2.6 source.

全局 CSS

若要自定义组件类,可使用 @layer components 指令。了解更多。

@layer components {  .toolbar {    @apply gap-4 rounded-lg bg-surface p-3;  }}

样式参考

HeroUI 遵循 BEM 方法论,确保组件变体与状态可复用且易于自定义。

CSS 类

Toolbar 使用以下 CSS 类(查看源码样式):

  • .toolbar - 基础容器
  • .toolbar--horizontal - 水平方向(默认)
  • .toolbar--vertical - 垂直方向
  • .toolbar--attached - Attached 变体:surface 背景与完全圆角

API 参考

Toolbar

继承 React Aria Toolbar。

Prop类型默认值描述
isAttachedbooleanfalseToolbar 是否使用带完全圆角的 surface 背景
orientation"horizontal" | "vertical""horizontal"Toolbar 的方向
aria-labelstring-Toolbar 的无障碍标签
aria-labelledbystring-用于标注该 Toolbar 的元素 id
childrenReact.ReactNode | (values: ToolbarRenderProps) => React.ReactNode-内容或渲染 prop
classNamestring | (values: ToolbarRenderProps) => string-额外的 CSS 类名

ToolbarRenderProps

使用渲染 prop 模式时,会提供以下值:

Prop类型描述
orientation"horizontal" | "vertical"当前 Toolbar 的方向

相关组件