Noctis

CopyButton

A clipboard button built on Button: it owns the copy itself, crossfades its glyph from clipboard to a check on success, and flips its accessible label — otherwise a plain Button you can dress for any context.

Standalone

Give it a getText callback — resolved at click time, so it can read live DOM — and the button copies and confirms on its own. With a visible label it reads as an ordinary action; the glyph still crossfades to a check and the accessible label flips to Copied for the brief confirmation window. Override copyLabel / copiedLabel to translate.

Code affordance

The icon-only form a code block reaches for: pass iconOnly and set copyLabel so assistive technology can announce the control without visible text. It sizes to the shared code-copy step so it aligns with a code tab strip, and the clipboard glyph swaps to a check the instant the copy lands.

import { CopyButton } from "@stridge/noctis";

<CopyButton iconOnly getText={() => snippet} />;

Design tokens

Generated from the component's declaration — the same graph that mints the CSS, so a variable name or its resolution default can't drift. The minted tokens are the public override seam: set one on any ancestor and every copy button in that region retunes — e.g. .docs-code { --noctis-code-copy-size: 2rem; } resizes every icon-only affordance beneath it. Knobs that aren't minted are reached through the part's data-slot. See Customization for the full override ladder and Tokens for the whole graph.

Token

API reference

Generated from the component's types — every prop, type, default, and description comes straight from the source. CopyButton extends the Button props (minus the onClick, aria-label, and title it owns), so variant, size, iconOnly, and the native button attributes pass straight through; expand a row for the full type and description.

Prop

AttributeDescription
data-slotMarks the rendered element as the copy affordance for styling and testing hooks.
data-copiedPresent for the brief window after a successful copy, while the glyph shows the check. Stamped on the root (a test/host hook) **and** on each glyph (self-contained — the crossfade rules key off the glyph's own `data-copied`, never a descendant `[data-copied] …` selector).
data-glyphWhich glyph a `code-copy-glyph` element paints — `clipboard` (at rest) or `check` (after copy).