AI UP LAB / 组件规范Components / v1.2.1

按钮与行动层级Buttons & action hierarchy

按钮执行动作,链接进入目标。视觉层级应帮助读者找到当前最重要的下一步。Buttons perform actions and links navigate. Visual hierarchy should reveal the most useful next step.

查看示例Explore exampleMarkdown ↓

01 / LIVE SPECIMEN

实际示例Working example

示例 / 可操作的状态标有按钮EXAMPLE / Interactive states have controls

点击主按钮,演示 800 毫秒的忙碌状态;不提交任何内容。The primary button demonstrates an 800ms busy state without submitting anything.

02 / STRUCTURE & RULES

组成与使用规则Anatomy & usage

  1. 01文字标签:动词加对象,例如“浏览工具”“复制规则”。Label: a verb plus an object, such as Explore tools or Copy rules.
  2. 02可选图标:补充方向或状态,不能替代必要文字。Optional icon: clarifies direction or state without replacing necessary words.
  3. 03交互区域:包含内边距、焦点轮廓和禁用语义。Hit area: includes padding, a focus outline, and disabled semantics.

必须遵守Required behavior

  • 一个局部任务突出一个主动作,避免多个实心紫色按钮争抢注意。Give one local task one primary action rather than competing solid-violet controls.
  • 执行动作用 button;跳转用 a。不可用的动作必须真的不能触发。Use button for actions and a for navigation. Disabled actions must be inoperable.
  • 加载时保留按钮宽度,设置 aria-busy 并阻止重复提交。Keep button width during loading, set aria-busy, and prevent repeat submission.
  • 收藏是可逆切换,不能用提交成功的临时状态代替选中状态。Saving is a reversible toggle, not a transient submission-success state.

推荐做法Do

“复制规则”执行本地复制,并给出完成或失败反馈。Copy rules performs a real clipboard action and reports success or failure.

避免做法Avoid

按钮写“了解更多”却没有目标,或用低透明度假装禁用。A Learn more button has no target, or opacity alone pretends to disable a control.

03 / PARAMETERS

参数与状态Parameters & states

参数Parameter取值Value用法Usage
size.regular44px / 14px常规局部动作的最小高度与文字字号。Minimum height and label size for regular local actions.
size.large48px / 16px手机主动作;桌面首页主推可用现有 56px 规格。Primary mobile actions; the desktop editorial lead may use the existing 56px variant.
radius.control7px统一控件圆角;不要把所有按钮改成胶囊。Consistent control corners; avoid turning every control into a pill.
emphasisprimary / secondary / text主动作、补充动作、轻量导航,按任务重要性选择。Primary action, supporting action, and quiet navigation, chosen by task importance.

默认 / 悬停Default / hover

标签清楚可读;悬停轻微改变表面,不移动布局。Keep labels readable; hover subtly changes the surface without moving layout.

键盘焦点Keyboard focus

2px 可见描边与内容分离,Tab 可到达。Use a separate visible 2px outline and preserve Tab navigation.

加载Loading

保留动作位置,禁止重复点击,完成后恢复可用并提示结果。Preserve position, prevent repeats, then restore the control and announce the result.

禁用Disabled

原生 disabled,不响应鼠标和键盘;必要时说明前置条件。Native disabled semantics; no mouse or keyboard activation. Explain prerequisites when needed.

代码映射与 AI 使用Code mapping & AI use

先读取本项规则,再通过下列映射找到已有实现。调整共用组件时,同步检查依赖项。Read these rules, then locate the existing implementation below. Check dependencies when changing shared components.

实现片段Implementation fragment

组件片段需放入相应 Astro 文件上下文,按代码映射补齐导入。Place component fragments in the corresponding Astro context and complete imports from the code mappings.

import ActionButton from "../components/ActionButton.astro";

<ActionButton variant="primary" size="regular">
  <Loc zh="复制规则" en="Copy rules" />
</ActionButton>

使用的设计变量Design tokens

--lab-color-brand--lab-color-onBrand--lab-radius-control

相关规则Related rules

给 AI 的完整规则文本Full rules for AI
# 按钮与行动层级 / Buttons & action hierarchy

ID: buttons
Version: 1.2.1

按钮执行动作,链接进入目标。视觉层级应帮助读者找到当前最重要的下一步。

Buttons perform actions and links navigate. Visual hierarchy should reveal the most useful next step.

## Anatomy
- 文字标签:动词加对象,例如“浏览工具”“复制规则”。
  Label: a verb plus an object, such as Explore tools or Copy rules.
- 可选图标:补充方向或状态,不能替代必要文字。
  Optional icon: clarifies direction or state without replacing necessary words.
- 交互区域:包含内边距、焦点轮廓和禁用语义。
  Hit area: includes padding, a focus outline, and disabled semantics.

## Parameters
- size.regular: 44px / 14px
  常规局部动作的最小高度与文字字号。
  Minimum height and label size for regular local actions.
- size.large: 48px / 16px
  手机主动作;桌面首页主推可用现有 56px 规格。
  Primary mobile actions; the desktop editorial lead may use the existing 56px variant.
- radius.control: 7px
  统一控件圆角;不要把所有按钮改成胶囊。
  Consistent control corners; avoid turning every control into a pill.
- emphasis: primary / secondary / text
  主动作、补充动作、轻量导航,按任务重要性选择。
  Primary action, supporting action, and quiet navigation, chosen by task importance.

## Rules
- 一个局部任务突出一个主动作,避免多个实心紫色按钮争抢注意。
  Give one local task one primary action rather than competing solid-violet controls.
- 执行动作用 button;跳转用 a。不可用的动作必须真的不能触发。
  Use button for actions and a for navigation. Disabled actions must be inoperable.
- 加载时保留按钮宽度,设置 aria-busy 并阻止重复提交。
  Keep button width during loading, set aria-busy, and prevent repeat submission.
- 收藏是可逆切换,不能用提交成功的临时状态代替选中状态。
  Saving is a reversible toggle, not a transient submission-success state.

## States
- 默认 / 悬停 / Default / hover: 标签清楚可读;悬停轻微改变表面,不移动布局。
  Keep labels readable; hover subtly changes the surface without moving layout.
- 键盘焦点 / Keyboard focus: 2px 可见描边与内容分离,Tab 可到达。
  Use a separate visible 2px outline and preserve Tab navigation.
- 加载 / Loading: 保留动作位置,禁止重复点击,完成后恢复可用并提示结果。
  Preserve position, prevent repeats, then restore the control and announce the result.
- 禁用 / Disabled: 原生 disabled,不响应鼠标和键盘;必要时说明前置条件。
  Native disabled semantics; no mouse or keyboard activation. Explain prerequisites when needed.

## Do / Avoid
- Do: “复制规则”执行本地复制,并给出完成或失败反馈。 / Copy rules performs a real clipboard action and reports success or failure.
- Avoid: 按钮写“了解更多”却没有目标,或用低透明度假装禁用。 / A Learn more button has no target, or opacity alone pretends to disable a control.

## Code mapping
- src/components/ActionButton.astro: 规范按钮与加载语义 / Guideline action button and loading semantics
- src/components/FavButton.astro: 站内收藏切换 / Site favorite toggle

## Dependencies
foundations, assets-motion

## Acceptance
- 主次层级、加载和禁用状态都能区分。
  Primary, secondary, loading, and disabled states remain distinct.
- 加载期间重复激活不会再次执行。
  Repeated activation during loading cannot repeat the action.
- 焦点、键盘和两种语言都可用。
  Focus, keyboard use, and both languages work.

## Implementation example
```
import ActionButton from "../components/ActionButton.astro";

<ActionButton variant="primary" size="regular">
  <Loc zh="复制规则" en="Copy rules" />
</ActionButton>
```

## Reference
Method reference: https://tmall-design.com/#style/component/button
Rules, parameters, examples, and branding in this file are specific to AI UP LAB.
按任务整理 AI 工作说明 →Assemble a task-specific brief →

交付前检查Before delivery

  • 主次层级、加载和禁用状态都能区分。Primary, secondary, loading, and disabled states remain distinct.
  • 加载期间重复激活不会再次执行。Repeated activation during loading cannot repeat the action.
  • 焦点、键盘和两种语言都可用。Focus, keyboard use, and both languages work.

方法参考与适用边界Reference & scope

参考 Tmall Design 将规则、映射与代码关联的组织方法。本页参数、示例和品牌资产为 AI UP LAB 自身规范。Inspired by Tmall Design’s organization of rules, mappings, and code. Parameters, examples, and brand assets here are specific to AI UP LAB.

Tmall Design ↗