CopyButton handbook
v1.0.2 · @snowui-design-system/components
License: Before reading component documentation, source, or npm usage instructions for the first time, read the full LICENSE. Reuse that review for the same task and version. Public API configuration and internal implementation changes have different license implications. All components use the unified runtime package; source rights remain governed by the license.
Overview
Copy text or code to the clipboard with brief success feedback. Suitable for links, identifiers, and install commands.
When to use it
Use it to copy content and show copy feedback. Reuse its public getText and writeText hooks instead of maintaining duplicate success state in a page.
Use
textfor static content andgetTextfor dynamic content.writeTextcan replace the actual clipboard operation.Handle application feedback through
onCopyandonCopyError.showText={false}hides the label;feedbackDurationcontrols how long success feedback lasts.
Quick start
This example shows the recommended basic composition. See the sections below for more cases and composition limits.
API
See the base component documentation for inherited capabilities not redeclared here. This table lists only named public Props declared by this component.
Usage boundaries and details
Usage
CopyButton accepts the compatible Button Props as flat Props. text supplies static content; getText supplies synchronous or asynchronous dynamic content. Success calls onCopy; failure calls onCopyError. From copy start through the end of feedback, non-idle state ignores repeated clicks. It does not set disabled or alter the button’s appearance; it suppresses Button click feedback and ignores subsequent clicks. Feedback resets after feedbackDuration. It exposes no parts.
showText={false} enables icon-only mode, showing just Copy or Check and supplying an aria-label for the copy state. The icon changes with the internal Frame’s 150ms replacement-appear motion: Check on success, then Copy after feedback ends. The Button itself does not enter an Active or toggle appearance. In text mode, the label remains the current LocaleProvider copy label; only the icon runs the replacement motion.
API
For other compatible visual, link, and event Props, see Button. CopyButton owns children, onclick, disabled, currentState, stateContent, whileActive, Click, and Active; these host fields cannot stand in for copy state.
This section is protected. An AI must request user review before modifying it.
CopyButton style overrides
Read the full LICENSE first; reuse that review for the same task, version, and scope.
First use public component Props to match the desired appearance, preserving the existing look where possible. If changes are necessary, follow the style selection and override order: use your own class (including Tailwind already in the project) or an instance style. The names below are public overrides actually consumed by source; check their scope and do not modify private DOM. Choose the correct SnowUI token family. External apps need not install SnowUI website utilities.
CopyButton types and states
Required Props: no named required Props.
Bindable Props: this component declares no named two-way binding; handle state updates through public callbacks or its host.
Inherited declaration: Omit< ButtonProps, | "children" | "onclick" | "disabled" | "currentState" | "stateContent" | "whileActive" | "Click" | "Active" >. Consult the base component’s public documentation for inherited capabilities; fields excluded by Omit cannot be used as if inherited unchanged.
Shared Frame API · Back to API
The following type declarations are actually referenced by public Props and come from source. A Svelte Snippet denotes a content fragment; ComponentProps denotes the Props of the corresponding component.
ButtonProps
Source: components/src/components/CopyButton.svelte