@apexhub/apex-ui-react 0.0.0-stage → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +37 -2
- package/dist/en_US.d.ts +191 -0
- package/dist/index.cjs +40692 -0
- package/dist/index.d.ts +6869 -0
- package/dist/index.mjs +40676 -0
- package/dist/llm/alert.tokens.txt +44 -0
- package/dist/llm/alert.txt +167 -0
- package/dist/llm/apex-provider.txt +368 -0
- package/dist/llm/auto-complete.tokens.txt +77 -0
- package/dist/llm/auto-complete.txt +373 -0
- package/dist/llm/avatar.tokens.txt +38 -0
- package/dist/llm/avatar.txt +199 -0
- package/dist/llm/breadcrumb.tokens.txt +193 -0
- package/dist/llm/breadcrumb.txt +251 -0
- package/dist/llm/button.tokens.txt +470 -0
- package/dist/llm/button.txt +262 -0
- package/dist/llm/card.tokens.txt +27 -0
- package/dist/llm/card.txt +95 -0
- package/dist/llm/cascader.tokens.txt +253 -0
- package/dist/llm/cascader.txt +898 -0
- package/dist/llm/checkbox.tokens.txt +28 -0
- package/dist/llm/checkbox.txt +332 -0
- package/dist/llm/collapse.tokens.txt +84 -0
- package/dist/llm/collapse.txt +330 -0
- package/dist/llm/date-picker.tokens.txt +171 -0
- package/dist/llm/date-picker.txt +424 -0
- package/dist/llm/divider.tokens.txt +22 -0
- package/dist/llm/divider.txt +161 -0
- package/dist/llm/drawer.tokens.txt +71 -0
- package/dist/llm/drawer.txt +369 -0
- package/dist/llm/dropdown.tokens.txt +59 -0
- package/dist/llm/dropdown.txt +420 -0
- package/dist/llm/form.tokens.txt +26 -0
- package/dist/llm/form.txt +341 -0
- package/dist/llm/grid.txt +419 -0
- package/dist/llm/image.tokens.txt +28 -0
- package/dist/llm/image.txt +428 -0
- package/dist/llm/input-number.tokens.txt +159 -0
- package/dist/llm/input-number.txt +486 -0
- package/dist/llm/input.tokens.txt +136 -0
- package/dist/llm/input.txt +422 -0
- package/dist/llm/layout.tokens.txt +29 -0
- package/dist/llm/layout.txt +298 -0
- package/dist/llm/menu.tokens.txt +87 -0
- package/dist/llm/menu.txt +680 -0
- package/dist/llm/message.tokens.txt +25 -0
- package/dist/llm/message.txt +301 -0
- package/dist/llm/modal.tokens.txt +96 -0
- package/dist/llm/modal.txt +584 -0
- package/dist/llm/notification.tokens.txt +79 -0
- package/dist/llm/notification.txt +383 -0
- package/dist/llm/pagination.tokens.txt +33 -0
- package/dist/llm/pagination.txt +208 -0
- package/dist/llm/popover.tokens.txt +28 -0
- package/dist/llm/popover.txt +233 -0
- package/dist/llm/progress.tokens.txt +83 -0
- package/dist/llm/progress.txt +279 -0
- package/dist/llm/radio.tokens.txt +21 -0
- package/dist/llm/radio.txt +348 -0
- package/dist/llm/rate.tokens.txt +20 -0
- package/dist/llm/rate.txt +241 -0
- package/dist/llm/select.tokens.txt +160 -0
- package/dist/llm/select.txt +830 -0
- package/dist/llm/skeleton.tokens.txt +15 -0
- package/dist/llm/skeleton.txt +275 -0
- package/dist/llm/spin.tokens.txt +21 -0
- package/dist/llm/spin.txt +294 -0
- package/dist/llm/steps.tokens.txt +30 -0
- package/dist/llm/steps.txt +300 -0
- package/dist/llm/switch.tokens.txt +38 -0
- package/dist/llm/switch.txt +216 -0
- package/dist/llm/table.tokens.txt +94 -0
- package/dist/llm/table.txt +1046 -0
- package/dist/llm/tabs.tokens.txt +78 -0
- package/dist/llm/tabs.txt +306 -0
- package/dist/llm/tag.tokens.txt +76 -0
- package/dist/llm/tag.txt +305 -0
- package/dist/llm/tooltip.tokens.txt +22 -0
- package/dist/llm/tooltip.txt +304 -0
- package/dist/llm/tree-select.tokens.txt +174 -0
- package/dist/llm/tree-select.txt +762 -0
- package/dist/llm/tree.tokens.txt +36 -0
- package/dist/llm/tree.txt +505 -0
- package/dist/llm/typography.tokens.txt +60 -0
- package/dist/llm/typography.txt +413 -0
- package/dist/llm/upload.tokens.txt +201 -0
- package/dist/llm/upload.txt +706 -0
- package/dist/llms-full.txt +16689 -0
- package/dist/llms-theme.txt +32 -0
- package/dist/llms.txt +59 -0
- package/dist/locale/en_US.cjs +160 -0
- package/dist/locale/en_US.d.ts +4 -0
- package/dist/locale/en_US.mjs +161 -0
- package/dist/locale/zh_CN.cjs +160 -0
- package/dist/locale/zh_CN.d.ts +4 -0
- package/dist/locale/zh_CN.mjs +161 -0
- package/dist/style.css +19619 -0
- package/dist/zh_CN.d.ts +191 -0
- package/llms-full.txt +16689 -0
- package/llms-theme.txt +32 -0
- package/llms.txt +59 -0
- package/package.json +118 -3
- package/src/alert/llm.txt +167 -0
- package/src/alert/tokens.txt +44 -0
- package/src/apex-provider/llm.txt +368 -0
- package/src/auto-complete/llm.txt +373 -0
- package/src/auto-complete/tokens.txt +77 -0
- package/src/avatar/llm.txt +199 -0
- package/src/avatar/tokens.txt +38 -0
- package/src/breadcrumb/llm.txt +251 -0
- package/src/breadcrumb/tokens.txt +193 -0
- package/src/button/llm.txt +262 -0
- package/src/button/tokens.txt +470 -0
- package/src/card/llm.txt +95 -0
- package/src/card/tokens.txt +27 -0
- package/src/cascader/llm.txt +898 -0
- package/src/cascader/tokens.txt +253 -0
- package/src/checkbox/llm.txt +332 -0
- package/src/checkbox/tokens.txt +28 -0
- package/src/collapse/llm.txt +330 -0
- package/src/collapse/tokens.txt +84 -0
- package/src/date-picker/llm.txt +424 -0
- package/src/date-picker/tokens.txt +171 -0
- package/src/divider/llm.txt +161 -0
- package/src/divider/tokens.txt +22 -0
- package/src/drawer/llm.txt +369 -0
- package/src/drawer/tokens.txt +71 -0
- package/src/dropdown/llm.txt +420 -0
- package/src/dropdown/tokens.txt +59 -0
- package/src/form/llm.txt +341 -0
- package/src/form/tokens.txt +26 -0
- package/src/grid/llm.txt +419 -0
- package/src/image/llm.txt +428 -0
- package/src/image/tokens.txt +28 -0
- package/src/input/llm.txt +422 -0
- package/src/input/tokens.txt +136 -0
- package/src/input-number/llm.txt +486 -0
- package/src/input-number/tokens.txt +159 -0
- package/src/layout/llm.txt +298 -0
- package/src/layout/tokens.txt +29 -0
- package/src/menu/llm.txt +680 -0
- package/src/menu/tokens.txt +87 -0
- package/src/message/llm.txt +301 -0
- package/src/message/tokens.txt +25 -0
- package/src/modal/llm.txt +584 -0
- package/src/modal/tokens.txt +96 -0
- package/src/notification/llm.txt +383 -0
- package/src/notification/tokens.txt +79 -0
- package/src/pagination/llm.txt +208 -0
- package/src/pagination/tokens.txt +33 -0
- package/src/popover/llm.txt +233 -0
- package/src/popover/tokens.txt +28 -0
- package/src/progress/llm.txt +279 -0
- package/src/progress/tokens.txt +83 -0
- package/src/radio/llm.txt +348 -0
- package/src/radio/tokens.txt +21 -0
- package/src/rate/llm.txt +241 -0
- package/src/rate/tokens.txt +20 -0
- package/src/select/llm.txt +830 -0
- package/src/select/tokens.txt +160 -0
- package/src/skeleton/llm.txt +275 -0
- package/src/skeleton/tokens.txt +15 -0
- package/src/spin/llm.txt +294 -0
- package/src/spin/tokens.txt +21 -0
- package/src/steps/llm.txt +300 -0
- package/src/steps/tokens.txt +30 -0
- package/src/switch/llm.txt +216 -0
- package/src/switch/tokens.txt +38 -0
- package/src/table/llm.txt +1046 -0
- package/src/table/tokens.txt +94 -0
- package/src/tabs/llm.txt +306 -0
- package/src/tabs/tokens.txt +78 -0
- package/src/tag/llm.txt +305 -0
- package/src/tag/tokens.txt +76 -0
- package/src/tooltip/llm.txt +304 -0
- package/src/tooltip/tokens.txt +22 -0
- package/src/tree/llm.txt +505 -0
- package/src/tree/tokens.txt +36 -0
- package/src/tree-select/llm.txt +762 -0
- package/src/tree-select/tokens.txt +174 -0
- package/src/typography/llm.txt +413 -0
- package/src/typography/tokens.txt +60 -0
- package/src/upload/llm.txt +706 -0
- package/src/upload/tokens.txt +201 -0
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
# Button
|
|
2
|
+
|
|
3
|
+
> Button:标记一个或多个操作(提交、确认、跳转等)时。
|
|
4
|
+
|
|
5
|
+
包:`@apexhub/apex-ui-react`;版本:`1.2.0`(当前源码快照,发布状态以安装包版本为准)。
|
|
6
|
+
|
|
7
|
+
公开导出:`Button`。
|
|
8
|
+
|
|
9
|
+
以下 API 属于 Apex UI;不要据 antd 的同名组件推断额外属性或默认值。默认值列的空缺表示未声明,不代表 `false`。
|
|
10
|
+
|
|
11
|
+
## 快速开始
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { Button } from '@apexhub/apex-ui-react'
|
|
15
|
+
|
|
16
|
+
import '@apexhub/apex-ui-react/style.css'
|
|
17
|
+
|
|
18
|
+
export default () => <Button type="primary">主要按钮</Button>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## 何时使用
|
|
22
|
+
|
|
23
|
+
- 标记一个或多个操作(提交、确认、跳转等)时。
|
|
24
|
+
- 需要在不同业务线、不同页面保持一致的按钮外观时。
|
|
25
|
+
- 需要在自定义元素上复用按钮样式时,使用 `asChild`。
|
|
26
|
+
|
|
27
|
+
## API
|
|
28
|
+
|
|
29
|
+
仅使用类型定义支持的属性;原生属性、ref 目标和事件签名因组件而异。关联类型用于解释字段结构;只有「导出类型」中的名称可从包根导入。
|
|
30
|
+
|
|
31
|
+
### Button
|
|
32
|
+
|
|
33
|
+
| 属性 | 说明 | 类型 | 必填 | 默认值 | 版本 |
|
|
34
|
+
| --- | --- | --- | --- | --- | --- |
|
|
35
|
+
| type | 按钮类型,控制外观样式<br>- `default`:默认边框按钮(白底)<br>- `primary`:主色实心按钮<br>- `danger`:危险操作(边框红色)<br>- `text`:纯文字,无边框无背景<br>- `link`:链接样式,无边框无背景<br>注:`tabCapsule` 为 Tabs capsule 内部变体,不在对外 API 中暴露。 | `"default" \| "primary" \| "danger" \| "text" \| "link"` | 否 | `'default'` | `0.1.0` |
|
|
36
|
+
| variant | Figma visual style. When provided, it overrides the style implied by `type`.<br>- `main`: solid emphasis<br>- `outline`: bordered emphasis<br>- `secondary`: neutral filled action<br>- `text` / `link`: low-emphasis actions<br>- `icon`: icon-only action with hover fill<br>- `icon-transparent`: icon-only action, fully transparent background | `"text" \| "link" \| "main" \| "outline" \| "secondary" \| "icon" \| "icon-transparent" \| null` | 否 | — | `0.1.0` |
|
|
37
|
+
| tone | Visual intent. `main`, `outline`, and `icon` support every tone;<br>`icon-transparent`, `secondary`, `text`, and `link` use `default`.<br>`secondary`, `text`, and `link` use `default`.<br>When omitted, the legacy `danger` type resolves to `error`; other types<br>resolve to `default`. | `"default" \| "error" \| "success" \| "warning" \| null` | 否 | — | `0.1.0` |
|
|
38
|
+
| size | 按钮尺寸(`medium` 32px / `small` 24px;水平内边距共用 `--button-spacing-padding-x`) | `"small" \| "medium" \| null` | 否 | `'medium'` | `0.1.0` |
|
|
39
|
+
| disabled | 是否禁用。禁用时不可点击,视觉降级 | `boolean` | 否 | `false` | — |
|
|
40
|
+
| loading | 是否显示加载状态。<br>loading 为 true 时:不可点击,icon 位置替换为 loading 指示器 | `boolean` | 否 | `false` | `0.1.0` |
|
|
41
|
+
| loadingIcon | 加载态自定义图标。仅在 `loading` 为 true 时生效;<br>未传时使用内置 SVG spinner。 | `React.ReactNode` | 否 | — | — |
|
|
42
|
+
| htmlType | 原生 `<button>` 的 type 属性。仅普通 button 模式生效,与 `href` / `asChild` 互斥。 | `"button" \| "submit" \| "reset"` | 否 | `'button'` | — |
|
|
43
|
+
| href | 跳转地址。指定时渲染为 `<a>` 并保留按钮样式,此时 `htmlType` 失效。<br>与 `asChild` 同时使用时以 `asChild` 为准。 | `string` | 否 | — | — |
|
|
44
|
+
| target | 链接 target。依赖 `href`,仅在 `href` 存在时生效。 | `string` | 否 | — | — |
|
|
45
|
+
| asChild | 将按钮的样式与 props 合并到直接子元素上,而非渲染内置 `<button>` / `<a>`。<br>用于多态组合——让任意元素(如 `<a>`、路由 `Link`)拥有按钮外观。<br>优先级高于 `href` / `htmlType`。 | `boolean` | 否 | `false` | `0.1.0` |
|
|
46
|
+
| icon | 前置图标。loading 为 true 时此 prop 被 loading 指示器替换 | `React.ReactNode` | 否 | — | — |
|
|
47
|
+
| block | 是否撑满父容器宽度(`display: flex; width: 100%`) | `boolean \| null` | 否 | `false` | `0.1.0` |
|
|
48
|
+
| className | 根节点类名 | `string` | 否 | — | — |
|
|
49
|
+
| style | 根节点内联样式(禁止硬编码色值,优先 CSS Token) | `React.CSSProperties` | 否 | — | — |
|
|
50
|
+
| onClick | 点击事件处理器。<br>- asChild / href 模式下,event.currentTarget 可能是任意 HTML 元素<br>- disabled 或 loading 状态下此事件不会触发 | `React.MouseEventHandler<HTMLElement>` | 否 | — | — |
|
|
51
|
+
| children | 按钮内容。仅 icon、无文案时建议同时传入 `aria-label`。 | `React.ReactNode` | 否 | — | — |
|
|
52
|
+
| ref | 转发到根元素的 ref(button 或 a)。<br>React 19 起 ref 作为普通 prop 传递,无需 forwardRef 包装 | `React.Ref<HTMLButtonElement \| HTMLAnchorElement>` | 否 | — | — |
|
|
53
|
+
|
|
54
|
+
### ButtonVariants
|
|
55
|
+
|
|
56
|
+
从 CVA 推断的 variant props 类型
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
type ButtonVariants = VariantProps<typeof buttonVariants>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### 导出类型
|
|
63
|
+
|
|
64
|
+
另可从 `@apexhub/apex-ui-react` 导入:`ButtonProps`(与上文子类型配合使用)。
|
|
65
|
+
|
|
66
|
+
## 约束
|
|
67
|
+
|
|
68
|
+
- `asChild` / `href` / 普通 `<button>` 三选一:同时传 `asChild` 与 `href` 时**以 `asChild` 为准**;`htmlType` 仅普通 button 模式生效。
|
|
69
|
+
- `target` 仅在 `href` 存在时生效;`loadingIcon` 仅在 `loading` 为 true 时生效。
|
|
70
|
+
- `disabled` 与 `loading` 都会拦截 `onClick`;二者不应同时表达同一状态。
|
|
71
|
+
- 仅图标、无文案时必须传 `aria-label`,否则屏幕阅读器无法朗读。
|
|
72
|
+
|
|
73
|
+
## 代码演示
|
|
74
|
+
|
|
75
|
+
### 外观类型
|
|
76
|
+
|
|
77
|
+
通过 `type` 控制外观:`default`、`primary`、`danger`、`text`、`link`。`main` / `outline` / `icon` 等 Figma 样式可通过 `variant` + `tone` 组合;显式传入 `variant` 时优先于 `type`。
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
import { Button } from '@apexhub/apex-ui-react'
|
|
81
|
+
|
|
82
|
+
export default () => (
|
|
83
|
+
<div style={{ display: 'flex', gap: 12, flexWrap: 'wrap', alignItems: 'center' }}>
|
|
84
|
+
<Button>默认</Button>
|
|
85
|
+
<Button type="primary">主要</Button>
|
|
86
|
+
<Button type="danger">危险</Button>
|
|
87
|
+
<Button type="text">文字</Button>
|
|
88
|
+
<Button type="link">链接</Button>
|
|
89
|
+
</div>
|
|
90
|
+
)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### 尺寸
|
|
94
|
+
|
|
95
|
+
提供 `medium`(默认)与 `small` 两种尺寸。
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
import { Button } from '@apexhub/apex-ui-react'
|
|
99
|
+
|
|
100
|
+
export default () => (
|
|
101
|
+
<div style={{ display: 'flex', gap: 12, alignItems: 'center' }}>
|
|
102
|
+
<Button size="small" type="primary">
|
|
103
|
+
小
|
|
104
|
+
</Button>
|
|
105
|
+
<Button size="medium" type="primary">
|
|
106
|
+
中(默认)
|
|
107
|
+
</Button>
|
|
108
|
+
</div>
|
|
109
|
+
)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### 加载态
|
|
113
|
+
|
|
114
|
+
`loading` 为 true 时按钮不可点击,前置图标区显示 loading 指示器;可通过 `loadingIcon` 自定义。仅图标无文案时建议传入 `aria-label`。
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
import { Button } from '@apexhub/apex-ui-react'
|
|
118
|
+
|
|
119
|
+
export default () => (
|
|
120
|
+
<div style={{ display: 'flex', gap: 12, alignItems: 'center', flexWrap: 'wrap' }}>
|
|
121
|
+
<Button loading>加载中</Button>
|
|
122
|
+
<Button type="primary" loading>
|
|
123
|
+
提交中
|
|
124
|
+
</Button>
|
|
125
|
+
<Button type="primary" loading loadingIcon={<span aria-hidden>⏳</span>}>
|
|
126
|
+
自定义图标
|
|
127
|
+
</Button>
|
|
128
|
+
<Button type="primary" loading aria-label="提交中" />
|
|
129
|
+
</div>
|
|
130
|
+
)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### 禁用状态
|
|
134
|
+
|
|
135
|
+
`disabled` 后按钮不可点击,视觉降级;该状态下不会触发 点击事件。
|
|
136
|
+
|
|
137
|
+
```tsx
|
|
138
|
+
import { Button } from '@apexhub/apex-ui-react'
|
|
139
|
+
|
|
140
|
+
export default () => (
|
|
141
|
+
<div style={{ display: 'flex', gap: 12, alignItems: 'center', flexWrap: 'wrap' }}>
|
|
142
|
+
<Button disabled>禁用</Button>
|
|
143
|
+
<Button type="primary" disabled>
|
|
144
|
+
禁用主要
|
|
145
|
+
</Button>
|
|
146
|
+
<Button type="danger" disabled>
|
|
147
|
+
禁用危险
|
|
148
|
+
</Button>
|
|
149
|
+
</div>
|
|
150
|
+
)
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### 前置图标
|
|
154
|
+
|
|
155
|
+
通过 `icon` 在文案前插入图标;`loading` 时 icon 区会被 loading 指示器替换。
|
|
156
|
+
|
|
157
|
+
```tsx
|
|
158
|
+
import { Button } from '@apexhub/apex-ui-react'
|
|
159
|
+
|
|
160
|
+
const StarIcon = () => (
|
|
161
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor" aria-hidden>
|
|
162
|
+
<path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z" />
|
|
163
|
+
</svg>
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
export default () => (
|
|
167
|
+
<div style={{ display: 'flex', gap: 12, alignItems: 'center', flexWrap: 'wrap' }}>
|
|
168
|
+
<Button icon={<StarIcon />}>带图标</Button>
|
|
169
|
+
<Button type="primary" icon={<StarIcon />}>
|
|
170
|
+
主要带图标
|
|
171
|
+
</Button>
|
|
172
|
+
<Button type="primary" icon={<StarIcon />} aria-label="收藏" />
|
|
173
|
+
</div>
|
|
174
|
+
)
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### 全宽
|
|
178
|
+
|
|
179
|
+
`block` 撑满父容器宽度。
|
|
180
|
+
|
|
181
|
+
```tsx
|
|
182
|
+
import { Button } from '@apexhub/apex-ui-react'
|
|
183
|
+
|
|
184
|
+
export default () => (
|
|
185
|
+
<div style={{ width: 300 }}>
|
|
186
|
+
<Button type="primary" block>
|
|
187
|
+
全宽按钮
|
|
188
|
+
</Button>
|
|
189
|
+
</div>
|
|
190
|
+
)
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### 链接按钮
|
|
194
|
+
|
|
195
|
+
指定 `href`(及可选 `target`)时渲染为 `<a>` 并保留按钮样式。
|
|
196
|
+
|
|
197
|
+
```tsx
|
|
198
|
+
import { Button } from '@apexhub/apex-ui-react'
|
|
199
|
+
|
|
200
|
+
export default () => (
|
|
201
|
+
<Button href="https://example.com" target="_blank" type="primary">
|
|
202
|
+
跳转链接
|
|
203
|
+
</Button>
|
|
204
|
+
)
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### 自定义渲染
|
|
208
|
+
|
|
209
|
+
`asChild` 开启后由直接子元素承载按钮属性;与 `href` 同时使用时以 `asChild` 为准。
|
|
210
|
+
|
|
211
|
+
```tsx
|
|
212
|
+
import { Button } from '@apexhub/apex-ui-react'
|
|
213
|
+
|
|
214
|
+
export default () => (
|
|
215
|
+
<Button asChild type="primary">
|
|
216
|
+
<a href="https://example.com" target="_blank" rel="noreferrer">
|
|
217
|
+
渲染为 <a> 标签
|
|
218
|
+
</a>
|
|
219
|
+
</Button>
|
|
220
|
+
)
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## DOM 结构
|
|
224
|
+
|
|
225
|
+
该入口未声明静态 `data-slot`;请使用公开的样式属性。
|
|
226
|
+
|
|
227
|
+
## 样式定制
|
|
228
|
+
|
|
229
|
+
优先使用本组件公开的尺寸、类型和状态属性。换肤与变量覆盖方式见 [主题指南](../../llms-theme.txt)。
|
|
230
|
+
|
|
231
|
+
需要定制具体样式时再读取 [Token 明细](./tokens.txt),其中包含用途、定义值及适用作用域。常规组件使用无需加载该文件。
|
|
232
|
+
|
|
233
|
+
## FAQ
|
|
234
|
+
|
|
235
|
+
### `asChild` 和 `href` 同时传了,以哪个为准?
|
|
236
|
+
|
|
237
|
+
以 `asChild` 为准。开启 `asChild` 后按钮属性会交给直接子元素承载,此时 `href` / `target` 不再生效,跳转行为请由子元素自行实现(如 `<a>` 或路由组件)。
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
### 只有图标、没有文案,怎么保证可访问性?
|
|
241
|
+
|
|
242
|
+
给按钮传 `aria-label` 描述操作含义,例如 `<Button icon={<SearchIcon />} aria-label="搜索" />`,否则读屏用户无法得知按钮用途。
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
### `disabled` 和 `loading` 有什么区别?
|
|
247
|
+
|
|
248
|
+
两者都会拦截 `onClick`。`disabled` 是「当前不可用」的静态状态;`loading` 是「正在处理」,额外把 icon 换成 spinner 并标记 `aria-busy="true"`,语义上告诉辅助技术操作进行中。
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
### `loading` 时为什么 `icon` 不见了?
|
|
252
|
+
|
|
253
|
+
这是预期行为。`loading` 为 true 时,前置图标区会被 loading 指示器替换,以避免图标与转圈同时出现造成视觉拥挤。
|
|
254
|
+
|
|
255
|
+
### 没有 antd 的 `ghost` / `dashed` / `shape`?
|
|
256
|
+
|
|
257
|
+
没有。Apex Button 刻意收敛:保留 `type` 五档,并新增 `variant` + `tone` 对齐 Figma;`size` 两档,加载态用布尔 `loading`(自定义图标走 `loadingIcon`)。需要更复杂的形态请用 `className` / `asChild` 自行扩展。
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
### `type="danger"` 和 `type="default"` 宽度不一致?
|
|
261
|
+
|
|
262
|
+
`1.0.0` 起 `outline` / `main` / `secondary` 变体统一最小宽度(80px)。请确认已安装 `@apexhub/apex-ui-react@1.0.0` 并引入 `style.css`。
|