CodeSnippet

Components/Media

Interactive docs page: https://wix-pages.com/design-system-documentation/#/component/codesnippet

Overview

Copy

CodeSnippet displays a piece of code or a terminal command and lets users copy it to the clipboard in a single click. Use it in documentation, onboarding flows, and developer-facing surfaces where people need to read or reuse exact code.

Do

  • Keep the content exact and copy-ready, what users see is what they paste.

Don't

  • Don't use it for regular, non-code text. Use <Text/> instead.
  • Don't put long multi-line code in the singleline variant. Use multiline instead.
  • Don't disable copy unless the snippet is purely illustrative.
  • Don't use it for values users need to edit. Use <Input/> instead.

Feature examples

Variants

  • inline - code inside running text
  • singleline - one command in a copyable box
  • multiline - a multi-line code block
Copy

Size

  • tiny
  • small (default for singleline / multiline)
  • medium

For inline, size inherits from the surrounding text unless set explicitly.

Copy

Developer examples

Wrap long lines

By default the multiline variant scrolls horizontally when a line overflows. Set wrapText to wrap long lines onto the next line instead.

__

Applies only to multiline.

Copy

Custom tooltip labels

Customize the copy tooltip with copyTooltipText (idle) and copiedTooltipText (right after a successful copy).

Copy

Disable copy

Set disableCopy to hide the copy button (for singleline / multiline) or render inline code as static, non-interactive text.

Copy

Copy a different value than shown

The copy action writes the displayed code to the clipboard by default. Use copyText to copy something different from what's shown.

Copy

Copy callback

onCopy fires after a successful clipboard write and receives the copied value.

Copy

Common use case examples

Install command

Surface the package install command at the top of documentation.

Copy

Usage example

Show a copy-ready quick-start block.

Copy

Inline references in body text

Use the inline variant to mark up specific text without breaking the flow.

Copy

In a Card

Pair it with a Card to present an install or setup step as a self-contained block.

Copy

In a SectionHelper

Drop an inline snippet into a SectionHelper to call out an exact command inside a tip.

Copy

In a FormField

Use a FormField label to present a copyable, read-only value such as an API key or ID.

Copy

Code

Copy

Props

NameTypeDefaultDescription
ariaLabelstring—Adds an aria-label to the root element.
code (required)string—Code to render inside the snippet.
copiedTooltipTextstring—Tooltip label shown right after a successful copy. Auto-reverts to copyTooltipText after 3 seconds. Defaults to 'Copied to clipboard'.
copyTextstring—Text written to the clipboard when the copy action is triggered. Defaults to code.
copyTooltipTextstring—Tooltip label shown while idle (before the user copies). Defaults to 'Copy to clipboard'.
dataHookstring—Applies a data-hook HTML attribute that can be used in tests.
disableCopybooleanfalseDisables copy functionality across all variants. For inline the code renders as static, non-interactive text; for singleline / multiline the copy button is hidden.
onCopy(copiedValue: string) => void—Fires after a successful clipboard write. Receives the value that was copied.
size"small" | "tiny" | "medium"—Controls the typography size. Defaults to 'small' for singleline and multiline; for inline, inherits from the surrounding text when omitted.
tooltipPropsOmit<Partial<TooltipProps>, "content">—Accepts props to forward to the <Tooltip/> that wraps the copy trigger, for example placement or delays. The snippet sets content itself, so use copyTooltipText and copiedTooltipText to customize the labels.
variant"inline" | "singleline" | "multiline"'singleline'Visual variant of the snippet.
wrapTextboolean—Wraps lines instead of using a horizontal scrollbar. Applicable only to the multiline variant.

Testkit

Import the driver matching your test environment:

Copy

Driver methods

MethodDescription
exists—
getCode—
isCopyable—
copyContent—
getCopyButtonAriaLabel—
getAriaLabel—
elementGets the component root element.
clickClicks on the component root element.
baseReturns UniDriver for the base element.

Changelog

  • 1.339.0 (2026-10-19) — maintenance release, no component-specific changes
  • 1.338.0 (2026-10-15) — maintenance release, no component-specific changes
  • 1.335.0 (2026-10-12) — maintenance release, no component-specific changes
  • 1.329.0 (2026-09-24) — maintenance release, no component-specific changes
  • 1.328.0 (2026-09-22) — maintenance release, no component-specific changes
  • 1.323.0 (2026-09-10) — maintenance release, no component-specific changes
  • 1.310.0 (2026-08-10) — maintenance release, no component-specific changes
  • 1.307.0 (2026-08-03) — maintenance release, no component-specific changes
  • 1.292.0 (2026-06-22) — maintenance release, no component-specific changes
  • 1.291.0 (2026-06-19) — maintenance release, no component-specific changes
  • 1.286.0 (2026-06-08) — maintenance release, no component-specific changes
  • 1.284.0 (2026-06-04) — feat: add component (#16274) — has visual changes

Last updated: 21 October 2026

Did this help?