Copy Button

将值复制到剪贴板,并短暂显示“已复制”确认,屏幕阅读器也会播报。

可用框架
  • Angular: 可用
  • Vue: 可用
  • React: 可用
  • React Native: 可用

用法

导入

ts
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.

选择器
sone-copy-button
输入
名称类型 默认值
value必填

The text that goes to the clipboard.

string—
label—$localize`Copy`
copiedLabel—$localize`Copied`
variantButtonVariant"outline"
size

Default: `sm`, or `icon-sm` when `iconOnly`.

ButtonSize | nullnull
iconOnly

Only the glyph; `label` / `copiedLabel` become its accessible name.

booleanfalse
disabledbooleanfalse
resetAfter

How long the "Copied" state lasts, in ms.

number1500
输出
名称类型
copied

The value reached the clipboard.

string
copyError

The clipboard refused the write.

unknown