For AI agents: the complete documentation index is available at https://a3s-lab.github.io/UI/llms.txt, the full documentation bundle is available at https://a3s-lab.github.io/UI/llms-full.txt, and this page is available as Markdown at https://a3s-lab.github.io/UI/components/snippet.md.

代码片段

把一个可复用的短命令或标识符与复制操作放在同一边界中,兼顾扫描和窄屏滚动。

实时预览
npm install @a3s-lab/ui

用法

<div class="snippet">
  <code>npm install @a3s-lab/ui</code><button type="button" class="btn copy-button" data-size="sm" data-copy-text="npm install @a3s-lab/ui"><span data-copy-label>Copy</span><span data-copy-feedback aria-live="polite"></span></button>
</div>

契约

接口值
根选择器.snippet
原生根元素<div>
状态ready, copied, error
事件—
方法—

产品边界

Snippet 不承担多行语法高亮、执行或下载。长代码使用 Highlighter,差异使用 Code Diff,实际执行由宿主处理。

组件只发布可复用的交互边界。数据获取、持久化、权限、可信内容与业务实体继续由宿主产品拥有。

可访问性

代码保持从左到右并可横向滚动;复制按钮有清楚名称和结果反馈,键盘用户无需选择文本即可复用。