Your next page is taking shape...

Opening Your Next Page…

Loading the guide and preparing its examples for you to explore. The page will appear here automatically when it’s ready, so you can keep this view open without refreshing.

Made for Preact. Built to be yours.

Composition & Layout

Copy Button

Copy Button copies an exact string and reports the result beside the control. Build a clear hierarchy with reusable structure, consistent spacing and semantic surfaces. Keep layout decisions close to the content they organize. Import it from @/components/kamod-ui/copy-button.

Source · API reference · Theming · Styles


Interactive Live Preview
Try it. Make it yours.
Setting the scene...

Interactive preview

Live Preact example Local preview theme · Responsive styles follow the preview widthFull width

Installation

Import Copy Button from @kamod-ch/ui/copy-button.

Install PackagesTerminal
pnpm add @kamod-ch/ui

Copy an example with @kamod-ch/ui or the matching @kamod-ch/ui/… subpath. The code block switches between those two installs. Connect The Global Theme CSS and Tailwind Source Detection before your first render.

Usage

Pass the exact value to copy. Keep a visible label, and use the status text when the action succeeds or can be retried.

Import SetupTypeScript
import { CopyButton } from "@kamod-ch/ui";

Choose a complete composition from the examples below; required child components and props vary by pattern.

Component Examples & Variants

Explore Copy Button in Different Contexts, from the starting pattern to the compositions below. Begin with Copy a Command, then compare the examples that match your content, state and layout. These are working patterns to adapt, not a list of interchangeable variant values: check the API Reference before using a prop or combining behaviors. Look at the surrounding labels, supporting text and spacing as well as the component itself.

Read the Result and Its Implementation Together. Use each showcase’s Code view to inspect imports and composition, or its Prompt view to prepare a setup or adaptation brief. Try the narrow preview and local theme controls before connecting real data, and use Reset to return an example to its initial state. Keep layout changes in class utilities where appropriate; follow the Component Styles Guide for hierarchy and the Theming Guide for shared surfaces and colors. The Accessibility Notes explain what to preserve when making those changes.

Copy a Command

Copy the Exact Text the Reader Should Use. Place CopyButton next to a command or identifier and pass that string as value. The control reports success or a retry without changing the source text.

Keep the label specific to what is copied, and leave the original text visible so people can still select it.

src/components/CopyButtonExample.tsx5 lines
import { CopyButton } from "@kamod-ch/ui/copy-button";

export const Example = () => (
  <CopyButton value="pnpm add @kamod-ch/ui" label="Copy command" subject="install command" />
);
API reference

Props and Data

Configure Copy Button using the contracts below. Read the documented options alongside the Source Definitions to understand which values your application supplies and which details the component owns. Start with a prop or helper, then follow its type link to inspect the declaration without leaving the page.

Props, slots and variants for this component.

API reference
Your API, from source

Type cards are extracted from this checkout’s TypeScript source at build time. Props inherited through HTMLAttributes, Omit or variant helpers remain references in those declarations; their fields are not flattened here. Match the reference to your installed version, and check a package’s exports before writing an import type. A type exported by a source file is not necessarily re-exported by @kamod-ch/ui.

Component Props

Read each option with its owning component. The
marker identifies required fields verified in that declaration. A ? means a field can be omitted; it does not promise a fallback value. Existing documented defaults remain alongside the descriptions. For callbacks, check the argument and return types before connecting your own state or services.
@kamod-ch/ui/copy-button6.3 KB min · 2.1 KB gzipSignals: none

CopyButton

CopyButtonProps

CopyButton documented props
Prop / typeDescription
class
string | SignalLike<string | undefined>CopyButtonProps

Configure class for CopyButton. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
className
string | SignalLike<string | undefined>CopyButtonProps

Configure className for CopyButton. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
disabled
boolean | SignalLike<boolean | undefined>CopyButtonProps

Configure disabled for CopyButton. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
iconOnly
booleanCopyButtonProps

Hide the visible label while retaining the accessible name and feedback.

Default
false
label
stringCopyButtonProps

Visible idle label; also the accessible name unless aria-label is supplied.

Default
"Copy"
onClick
MouseEventHandler<HTMLButtonElement>CopyButtonProps

Configure onClick for CopyButton. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
onCopy
((value: string) => void)CopyButtonProps

Called only after a successful write for the current value.

Default
—
onCopyError
((error: unknown) => void)CopyButtonProps

Configure onCopyError for CopyButton. Compare its accepted type with the Usage Guidance before supplying a value.

Default
—
renderControl
((context: CopyButtonContext) => ComponentChildren)CopyButtonProps

Customize placement or semantics; the component retains its live status region.

Default
—
statusId
stringCopyButtonProps

Optional stable ID for the live region when another control references it.

Default
—
subject
stringCopyButtonProps

Short description used in success/error announcements, such as "code" or "payment ID".

Default
"text"
value
stringCopyButtonProps

Exact text written to the clipboard, independent of its visible presentation.

Default
—

Data Type Reference

Expand a card to inspect and copy the exact declaration. The code header identifies its repository file; follow imported or inherited types in the Implementation Source when you need the complete dependency chain. Required-field summaries cover fields declared directly in that type. Source-only helpers and inferred schema outputs describe the local implementation, not additional props you can pass to every component.

CopyStatus

Declaration
CopyStatus
Exported Source Declaration from copy-button-types.ts. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of CopyStatus before adapting it.

CopyButtonContext

4 declared fields
CopyButtonContext
Compose the existing button without starting a second clipboard lifecycle. Inspect the Complete Definition of CopyButtonContext before adapting it.
Required fields
status, statusId, copy, defaultControl

CopyButton Props

8 declared fields
CopyButtonProps
Exported Source Declaration from copy-button-types.ts. Referenced types retain their original names; inspect that file for imports and supporting definitions. Inspect the Complete Definition of CopyButtonProps before adapting it.
Required fields
value

Accessibility

CopyButton is a native button that copies the exact value string and reports success or a retry beside the control. The copied text stays visible, and the status is separate from the source.

Take the Next Useful Step

You have the pieces. Put them into one real interaction, keep its state in one place, and check the result with the content your application will actually show.

Connect the Foundation

Return to Choose and Compose Components to connect this reference to a working screen. Keep global CSS in one entrypoint and import only the components that screen needs.

Build the Surrounding Screen

Find a neighboring interaction in the Component Library, or start with a complete Block. Replace sample content and destinations before refining the layout; a local class change can stay with the composition.

Make the Result Hold Up

Use shared theme roles for changes that belong everywhere. Then review the whole journey: keyboard focus, long labels, narrow screens and a clear way to recover when something fails.

Keep a link to the source and note your intentional changes. Your next edit should begin with a clear decision, not another search.