> To build a Wix site agentically, or add Wix features like bookings or a store to a site you already have, follow https://www.wix.com/headless/skill.md
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

## Resource: CodeSnippet Component

## Article: CodeSnippet Component

## Article Link: https://dev.wix.com/docs/wix-design-system/components/media/code-snippet-component.md

## Article Content:

# CodeSnippet

_Components/Media_

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

## Overview

```jsx
() => (
  <Box align="center">
    <StorybookComponents.Stack flexDirection="column">
      {' '}
      <CodeSnippet code="yarn add @wix/design-system" variant="singleline" />
      <Text size="small" secondary>
        Run the command above, then import a component like{' '}
        <CodeSnippet code="Button" variant="inline" /> from the package.
      </Text>
      <CodeSnippet
        variant="multiline"
        code={`import { Button } from '@wix/design-system';

export default function App() {
  return <Button priority="primary">Get started</Button>;
}`}
      />
    </StorybookComponents.Stack>{' '}
  </Box>
);
```

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

```jsx
<StorybookComponents.Stack flexDirection="column">
  <Text>
    Pass the <CodeSnippet code="--verbose" variant="inline" /> flag to see debug
    output.
  </Text>

  <CodeSnippet code="yarn add @wix/design-system" variant="singleline" />

  <CodeSnippet
    variant="multiline"
    code={`{
  "scripts": {
    "build": "wix build",
    "start": "wix start"
  }
}`}
  />
</StorybookComponents.Stack>;
```

#### Size

- `tiny`
- `small` (default for `singleline` / `multiline`)
- `medium`

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

```jsx
<StorybookComponents.Stack flexDirection="column">
  <CodeSnippet
    code="yarn add @wix/design-system"
    variant="singleline"
    size="tiny"
  />

  <CodeSnippet
    code="yarn add @wix/design-system"
    variant="singleline"
    size="small"
  />

  <CodeSnippet
    code="yarn add @wix/design-system"
    variant="singleline"
    size="medium"
  />
</StorybookComponents.Stack>;
```

### 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`._

```jsx
() => {
  const code = `import { Button } from '@wix/design-system';

export default function App() {
  return <Button priority="primary">Get started</Button>;
}`;
  return (
    <StorybookComponents.Stack>
      <Box direction="vertical" gap="4px" width="320px">
        <Text size="tiny" secondary>
          wrapText=false (scrolls)
        </Text>

        <CodeSnippet variant="multiline" code={code} />
      </Box>

      <Box direction="vertical" gap="4px">
        <Text size="tiny" secondary>
          wrapText
        </Text>

        <CodeSnippet wrapText variant="multiline" code={code} />
      </Box>
    </StorybookComponents.Stack>
  );
};
```

#### Custom tooltip labels

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

```jsx
<StorybookComponents.Stack>
  <CodeSnippet
    code="wix_api_key_8f3a2b9c"
    variant="singleline"
    copyTooltipText="Copy API key"
    copiedTooltipText="API key copied"
  />
</StorybookComponents.Stack>;
```

#### Disable copy

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

```jsx
<StorybookComponents.Stack flexDirection="column" gap={4}>
  <CodeSnippet code="GET /v1/products" variant="singleline" disableCopy />

  <Text size="tiny" secondary>
    Read-only example — no copy button.
  </Text>
</StorybookComponents.Stack>;
```

#### 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.

```jsx
<StorybookComponents.Stack flexDirection="column" gap={4}>
  <CodeSnippet
    code="npm install @wix/design-system"
    copyText="npm install @wix/design-system --save-exact"
    variant="singleline"
  />

  <Text size="tiny" secondary>
    Shows the short command but copies it with the --save-exact flag.
  </Text>
</StorybookComponents.Stack>;
```

#### Copy callback

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

```jsx
() => {
  const [copiedCount, setCopiedCount] = React.useState(0);

  return (
    <StorybookComponents.Stack flexDirection="column" gap={4}>
      <CodeSnippet
        code="yarn add @wix/design-system"
        variant="singleline"
        onCopy={() => setCopiedCount((count) => count + 1)}
      />

      <Text size="small">Copied {copiedCount} times</Text>
    </StorybookComponents.Stack>
  );
};
```

### Common use case examples

#### Install command

Surface the package install command at the top of documentation.

```jsx
<StorybookComponents.Stack flexDirection="column" gap={8}>
  <Text weight="bold">Installation</Text>

  <Text size="small" secondary>
    Add the package to your project:
  </Text>

  <CodeSnippet code="yarn add @wix/design-system" variant="singleline" />
</StorybookComponents.Stack>;
```

#### Usage example

Show a copy-ready quick-start block.

```jsx
<StorybookComponents.Stack flexDirection="column" gap={8}>
  <Text weight="bold">Quick start</Text>

  <CodeSnippet
    variant="multiline"
    code={`import { WixDesignSystemProvider, Button } from '@wix/design-system';

export default function App() {
  return (
    <WixDesignSystemProvider>
      <Button>Click me</Button>
    </WixDesignSystemProvider>
  );
}`}
  />
</StorybookComponents.Stack>;
```

#### Inline references in body text

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

```jsx
<StorybookComponents.Stack>
  <Text>
    The <CodeSnippet code="priority" variant="inline" /> prop accepts{' '}
    <CodeSnippet code="primary" variant="inline" /> or{' '}
    <CodeSnippet code="secondary" variant="inline" />, and defaults to{' '}
    <CodeSnippet code="secondary" variant="inline" />.
  </Text>
</StorybookComponents.Stack>;
```

#### In a Card

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

```jsx
<Card>
  <Card.Header
    title="Install the package"
    subtitle="Add @wix/design-system to your project"
  />

  <Card.Content>
    <CodeSnippet code="yarn add @wix/design-system" variant="singleline" />
  </Card.Content>
</Card>;
```

#### In a SectionHelper

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

```jsx
<SectionHelper title="Before you start" appearance="standard">
  Run <CodeSnippet code="yarn build" variant="inline" /> from the repo root
  before launching the dev server.
</SectionHelper>;
```

#### In a FormField

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

```jsx
<FormField label="API key">
  <CodeSnippet
    code="wix_api_key_8f3a2b9c"
    variant="singleline"
    copyTooltipText="Copy API key"
    copiedTooltipText="Copied"
  />
</FormField>;
```

## Code

```jsx
import { CodeSnippet } from '@wix/design-system';
```

### Props

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `ariaLabel` | `string` | — | Adds an `aria-label` to the root element. |
| `code` *(required)* | `string` | — | Code to render inside the snippet. |
| `copiedTooltipText` | `string` | — | Tooltip label shown right after a successful copy. Auto-reverts to `copyTooltipText` after 3 seconds. Defaults to `'Copied to clipboard'`. |
| `copyText` | `string` | — | Text written to the clipboard when the copy action is triggered. Defaults to `code`. |
| `copyTooltipText` | `string` | — | Tooltip label shown while idle (before the user copies). Defaults to `'Copy to clipboard'`. |
| `dataHook` | `string` | — | Applies a `data-hook` HTML attribute that can be used in tests. |
| `disableCopy` | `boolean` | `false` | Disables 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. |
| `tooltipProps` | `Omit<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. |
| `wrapText` | `boolean` | — | Wraps lines instead of using a horizontal scrollbar. Applicable only to the `multiline` variant. |

## Testkit

Import the driver matching your test environment:

```jsx
// UniDriver
import { CodeSnippetUniDriver } from '@wix/design-system/dist/testkit/unidriver';

// Vanilla
import { CodeSnippetTestkit } from '@wix/design-system/dist/testkit';

// Puppeteer
import { CodeSnippetTestkit } from '@wix/design-system/dist/testkit/puppeteer';

// Testing Library
import { CodeSnippetTestkit } from '@wix/design-system/dist/testkit/testing-library';
```

### Driver methods

| Method | Description |
| --- | --- |
| `exists` | — |
| `getCode` | — |
| `isCopyable` | — |
| `copyContent` | — |
| `getCopyButtonAriaLabel` | — |
| `getAriaLabel` | — |
| `element` | Gets the component root element. |
| `click` | Clicks on the component root element. |
| `base` | Returns 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](invalid-url)) — has visual changes