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…
Composition
AnatomySnippet 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.
Snippet (div)
├── pre > code — lines, symbol aria-hidden
├── IconButton — copy (aria-label)
└── span[role=status] — Copied / Copy failedA place to start
UsageImport the stylesheet once at your application root. This complete example reflects the properties selected above.
Loading example…
Details that make a difference
Examples & statesVisual treatments
Emphasis changes presentation while the primitive keeps behavior.
Loading source…
Semantic colors
Semantic color supplements the selected state or measurement.
Loading source…
Sizes
Compare the three Dixy shirt sizes side by side.
Loading source…
Corner radii
Contextual rounding applies to the control or surface; large panels stay readable.
Loading source…
Materials
Optional static finishes use the same public component. Import materials.css in your application.
Loading source…
The finer details
API referenceGenerated from Dixy’s local TypeScript interfaces. Native HTML attributes and refs are forwarded. The table covers Dixy’s own options.
Snippet
| Prop | Type / description | Default |
|---|---|---|
color | VisualColorSemantic 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. | — |
as | EOverride the semantic element, e.g. a title heading level. | — |
children* | stringThe command or code to show. Line breaks are preserved. | — |
copyValue | stringText to copy when it differs from what is shown. | children |
symbol | stringA leading prompt such as "$". Shown on every line, never copied or announced. | — |
variant | "soft" | "solid" | "outline"Surface emphasis. | soft |
copyLabel | stringAccessible name of the copy button. | Copy to clipboard |
copiedLabel | stringStatus message announced after a successful copy. | Copied |
failedLabel | stringStatus message announced when the clipboard is unavailable. | Copy failed |
timeout | numberHow long the copied state lasts, in milliseconds. | 2000 |
hideCopyButton | booleanHide 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 tokensChange 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.
| Token | Purpose |
|---|---|
--dixy-color-background-subtle | The component-specific starting point. |
--dixy-font-label-md | Control label font and line height; body roles remain readable in text inputs. |
--dixy-color-background-selected | Selected surfaces use semantic color across appearances. |
--dixy-color-border-focus | Focus indication remains visible independently of shadows. |
--dixy-spacing-inset-sm | Density-aware component padding. |
--dixy-motion-transition-feedback | Short state feedback, reduced by the inherited motion setting. |
Consider everyone
AccessibilityThe 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.
Target: WCAG 2.2 AA. Automated tests cover selected behavior; manual screen-reader, contrast, and zoom validation remain part of the release checklist.
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.
--dixy-color-background-subtle