Components
CopySnippet 命令行代码块
面向开发者文档、CLI 工具安装与云平台运维指引的命令行复合块,支持多包管理器/环境无缝切换与一键复制。
多包管理器安装命令
通过 commands 数组配置 bun、pnpm、npm、yarn 等多环境命令,自动呈现切换标签。
bun add @elysola/ui<CopySnippet
:commands="[
{ label: 'bun', command: 'bun add @elysola/ui' },
{ label: 'pnpm', command: 'pnpm add @elysola/ui' },
{ label: 'npm', command: 'npm install @elysola/ui' },
{ label: 'yarn', command: 'yarn add @elysola/ui' }
]"
variant="outline"
/>单行命令行与变体
支持 subtle、outline 与 ghost 边框变体,可自定义命令行前缀符。
curl -fsSL https://elysola.org/install.sh | bashkubectl get pods -n elysola-prod --watch<CopySnippet
command="curl -fsSL https://elysola.org/install.sh | bash"
variant="subtle"
/>API 参考
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
command | string | '' | 单命令文本。 |
commands | CopySnippetCommand[] | [] | 多命令数组(包含 label、command、可选 prefix),展示顶部切换标签。 |
prefix | string | '$' | 命令行前缀提示符(例如 $ 或 >)。 |
variant | 'subtle' | 'outline' | 'ghost' | 'subtle' | 视觉层级变体。 |
copyable | boolean | true | 是否开启一键复制按钮与反馈。 |