ContentComponentBeta

Snippet.

A command, ready to copy.

Snippet shows code or a command with a copy button. A prompt symbol can lead each line without being copied or announced. The result is announced through a polite status region, and failure is reported, not hidden.

Make it yours

Preparing the example…

PROPERTIES7

Composition

Anatomy

Snippet shows code or a command with a copy button. A prompt symbol can lead each line without being copied or announced. The result is announced through a polite status region, and failure is reported, not hidden.

Component structure
Snippet (div)
├── pre > code — lines, symbol aria-hidden
├── IconButton — copy (aria-label)
└── span[role=status] — Copied / Copy failed

A place to start

Usage

Import the stylesheet once at your application root. This complete example reflects the properties selected above.

Loading example…

Details that make a difference

Examples & states

Visual treatments

Emphasis changes presentation while the primitive keeps behavior.

Example loads as it comes into view.

Loading source…

Semantic colors

Semantic color supplements the selected state or measurement.

Example loads as it comes into view.

Loading source…

Sizes

Compare the three Dixy shirt sizes side by side.

Example loads as it comes into view.

Loading source…

Corner radii

Contextual rounding applies to the control or surface; large panels stay readable.

Example loads as it comes into view.

Loading source…

Materials

Optional static finishes use the same public component. Import materials.css in your application.

Example loads as it comes into view.

Loading source…

The finer details

API reference

Generated from Dixy’s local TypeScript interfaces. Native HTML attributes and refs are forwarded. The table covers Dixy’s own options.

Snippet

PropType / descriptionDefault
colorVisualColor

Semantic color.

accent
size"sm" | "md" | "lg"

Component proportions.

md
radius"none" | "sm" | "md" | "lg" | "full"

Inherits the nearest Theme.

—
material"matte" | "glossy" | "soft" | "metal" | "paper"

Optional static finish; import materials.css. Inherits Theme.

—
asE

Override the semantic element, e.g. a title heading level.

—
children*string

The command or code to show. Line breaks are preserved.

—
copyValuestring

Text to copy when it differs from what is shown.

children
symbolstring

A leading prompt such as "$". Shown on every line, never copied or announced.

—
variant"soft" | "solid" | "outline"

Surface emphasis.

soft
copyLabelstring

Accessible name of the copy button.

Copy to clipboard
copiedLabelstring

Status message announced after a successful copy.

Copied
failedLabelstring

Status message announced when the clipboard is unavailable.

Copy failed
timeoutnumber

How long the copied state lasts, in milliseconds.

2000
hideCopyButtonboolean

Hide the copy action, e.g. for read-only output.

false
onCopy((value: string) => void)

Called with the copied text after the clipboard write succeeds.

—

Built from the same foundations

Styling tokens

Change Theme settings above to compare appearance, accent, neutral, radius, spacing density, motion and direction. Override component aliases on a Theme root so custom properties follow portaled content too. The wrapper merges className, style, refs and render composition with its owning primitive.

TokenPurpose
--dixy-color-background-subtleThe component-specific starting point.
--dixy-font-label-mdControl label font and line height; body roles remain readable in text inputs.
--dixy-color-background-selectedSelected surfaces use semantic color across appearances.
--dixy-color-border-focusFocus indication remains visible independently of shadows.
--dixy-spacing-inset-smDensity-aware component padding.
--dixy-motion-transition-feedbackShort state feedback, reduced by the inherited motion setting.
Explore theme customization

Consider everyone

Accessibility

The copy button keeps a constant name; the outcome is announced via role=status. The icon swap is not the only signal. Target WCAG 2.2 AA. Automated axe checks pass in unit tests; screen-reader, forced-colors and contrast verification in real browsers remains pending.

TabMove focus to the copy button.
Enter / SpaceCopy and announce the result.

Target: WCAG 2.2 AA. Automated tests cover selected behavior; manual screen-reader, contrast, and zoom validation remain part of the release checklist.

THE THINKING BEHIND IT

Build it. Then understand it.

Async side effects need a failure path and timer cleanup: the copied state resets after timeout and is cleared on unmount.

A token to follow--dixy-color-background-subtle

Nothing up our sleeves

Source
UP NEXTPassword Field