AsterUIDocsv1.0.2

Docs / Component reference

CopyButton & CodeBlock

Copy text without making the reader select it first. CodeBlock pairs the action with a filename and its contents.

Copy button example

Install

sh
npx @fierst/ui@1.0.2 add copy-button

Registry dependencies: theme, icon. Package dependencies: @lucide/icons.

Exports from ./ui/copy-button: CopyButton, CodeBlock.

Download the registry source for copy-button 1.0.2.

API contracts

ts
export function* CopyButton(
  props: {
    text: string;
    label?: string;
    copiedLabel?: string;
    resetMs?: number;
    onCopy?: () => void;
    onError?: (error: unknown) => void;
    class?: string;
  },
  ctx: Ctx,
)

export function CodeBlock({
  code,
  filename,
  class: extraClass,
}: {
  code: string;
  filename?: string;
  class?: string;
})