For AI agents: the complete documentation index is available at https://ifhover.github.io/leaf-ui/v/0.6.0/llms.txt, the full documentation bundle is available at https://ifhover.github.io/leaf-ui/v/0.6.0/llms-full.txt, and this page is available as Markdown at https://ifhover.github.io/leaf-ui/v/0.6.0/api/theme-tokens.md.
  • 简体中文
  • 主题变量

    日常定制优先设置 ConfigProvider 的 theme.primaryColor、theme.borderRadius 和 theme.controlHeight,其他样式会自动派生,见定制主题。

    LeafThemeTokens

    需要单独调整某个派生值时,再通过 theme.tokens 覆盖。所有字段均可选,嵌套区域继承未设置的字段。长度为数字时按 px 处理,动效时长为数字时按 ms 处理。

    属性类型默认值说明
    onPrimaryColorstring按主题生成主题背景上的文字色
    dangerColorstring按外观生成危险色 / 危险背景上的文字色
    onDangerColorstring按外观生成危险色 / 危险背景上的文字色
    successColorstring按外观生成成功 / 警告 / 信息颜色
    warningColorstring按外观生成成功 / 警告 / 信息颜色
    infoColorstring按外观生成成功 / 警告 / 信息颜色
    textColorstring按外观生成主要 / 次要文字
    mutedTextColorstring按外观生成主要 / 次要文字
    subtleTextColorstring—更轻的辅助文字色。
    surfaceColorstring按外观生成表面 / 次级表面
    mutedSurfaceColorstring按外观生成表面 / 次级表面
    raisedSurfaceColorstring—浮层与抬升表面色。
    borderColorstring按外观生成中性边框
    borderHoverColorstring—悬停时的中性边框色。
    dividerColorstring—分区分隔线颜色;默认从边框和表面颜色派生。
    borderRadiusSmnumber | string基础圆角 × 0.6单独覆盖小 / 大圆角
    borderRadiusMdnumber | string基础圆角 × 1.2单独覆盖卡片、提示等内容表面的中圆角
    borderRadiusLgnumber | string基础圆角 × 1.6单独覆盖大圆角
    controlHeightSmnumber | string基础高度 − 6px,最小 1px单独覆盖小尺寸控件高度
    controlHeightLgnumber | string基础高度 + 6px单独覆盖大尺寸控件高度
    fontSizeSmnumber | string基础字号 − 1px单独覆盖小 / 大字号
    fontSizeLgnumber | string基础字号 + 2px单独覆盖大字号
    fontWeightnumber500按钮、标签与组件标题的强调字重
    motionDurationnumber | string200基础过渡时间;数字为 ms,也支持 CSS 时间。motion=false 时为 0。
    motionEasingstring'cubic-bezier(0.22, 1, 0.36, 1)'悬停、内容与普通过渡的曲线。
    motionSpringstring'cubic-bezier(0.22, 1.28, 0.36, 1)'选择与形状变化的轻微弹性曲线。
    popupZIndexnumber1000浮层 / 弹窗 / 消息层级
    modalZIndexnumber1100浮层 / 弹窗 / 消息层级
    messageZIndexnumber1200浮层 / 弹窗 / 消息层级
    buttonBorderRadiusnumber | string当前控件尺寸仅按钮的圆角 / 共用高度覆盖
    buttonHeightnumber | string当前控件尺寸仅按钮的圆角 / 共用高度覆盖
    choiceBorderRadiusnumber | string基础圆角 × 0.5复选框圆角
    focusColorstring当前语义色自动生成焦点轮廓颜色
    primaryHoverColorstring主题色自动生成主色悬停 / 按下
    primaryActiveColorstring主题色自动生成主色悬停 / 按下
    primarySoftColorstring主题色自动生成主色柔和背景与交互状态
    primarySoftHoverColorstring主题色自动生成主色柔和背景与交互状态
    primarySoftActiveColorstring主题色自动生成主色柔和背景与交互状态
    primaryBorderColorstring主题色自动生成主题色边框
    dangerHoverColorstring危险色自动生成危险状态悬停 / 按下
    dangerActiveColorstring危险色自动生成危险状态悬停 / 按下
    spacingSmnumber | string—设置 spacingSm。
    spacingLgnumber | string—设置 spacingLg。
    shadowSmstring—设置 shadowSm。
    shadowXsstring—最轻的表面阴影。
    shadowMdstring—设置 shadowMd。
    shadowLgstring—设置 shadowLg。
    lineHeightnumber—正文行高。

    类型导入

    import type { LeafThemeTokens } from '@ifhover/leaf-ui';
    
    const tokens = {
      controlHeightSm: 28,
      borderRadiusLg: 14,
    } satisfies LeafThemeTokens;

    将该对象传给 <ConfigProvider theme={{ tokens }}>。

    LeafComponentTokens

    供 theme.components 按组件名称覆盖样式。各组件支持的字段以组件文档为准。

    属性类型说明
    borderRadiusstring | number圆角;数字表示像素。
    controlHeightstring | number控件高度;数字表示像素。
    paddingstring | number内容内边距。
    gapstring | number子项之间的间距。
    fontSizestring | number字号;数字表示像素。
    colorstring颜色或语义色。
    backgroundstring组件表面背景。
    borderColorstring外层边框与分区分隔线颜色。
    headerBackgroundstring标题区域背景。
    footerBackgroundstring底部操作区域背景。
    shadowstringCSS box-shadow 的值。

    LeafThemeStyle

    带 --leaf-* 自定义属性的 React 样式类型。业务 CSS 读取变量的示例见 定制主题。

    属性类型说明
    [key: `--leaf-${string}`]string | number | undefined可复用的 CSS 自定义属性。