Copy Button
将值复制到剪贴板,并短暂显示“已复制”确认,屏幕阅读器也会播报。
可用框架
Angular: 可用 Vue: 可用 React: 可用 React Native: 可用
用法
<div class="demo-row" style="align-items: center">
<sone-copy-button value="npm install @surface-one/angular" />
<sone-copy-button value="mtg_01J9ZK3Q7R4M2" label="Copy meeting ID" iconOnly variant="ghost" />
<sone-copy-button value="{ "mcpServers": {} }" label="Copy config" variant="secondary" />
</div>导入
import {
SoneCopyButtonComponent,
} from "@surface-one/angular/copy-button";API 参考
SoneCopyButtonComponent组件
Copies `value` to the clipboard from the click handler (nothing runs on the server), swaps to a "Copied" state for `resetAfter` ms and announces it in a polite live region.
| 名称 | 类型 | 默认值 |
|---|---|---|
value必填The text that goes to the clipboard. | string | — |
label | — | $localize`Copy` |
copiedLabel | — | $localize`Copied` |
variant | ButtonVariant | "outline" |
sizeDefault: `sm`, or `icon-sm` when `iconOnly`. | ButtonSize | null | null |
iconOnlyOnly the glyph; `label` / `copiedLabel` become its accessible name. | boolean | false |
disabled | boolean | false |
resetAfterHow long the "Copied" state lasts, in ms. | number | 1500 |
| 名称 | 类型 |
|---|---|
copiedThe value reached the clipboard. | string |
copyErrorThe clipboard refused the write. | unknown |