## Feature Examples

### Variants
- description: - `inline` - code inside running text - `singleline` - one command in a copyable box - `multiline` - a multi-line code block
- example:
```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
- description: - `tiny` - `small` (default for `singleline` / `multiline`) - `medium` For `inline`, size inherits from the surrounding text unless set explicitly.
- example:
```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
- description: 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`._
- example:
```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
- description: Customize the copy tooltip with `copyTooltipText` (idle) and `copiedTooltipText` (right after a successful copy).
- example:
```jsx
<StorybookComponents.Stack>
  <CodeSnippet
    code="wix_api_key_8f3a2b9c"
    variant="singleline"
    copyTooltipText="Copy API key"
    copiedTooltipText="API key copied"
  />
</StorybookComponents.Stack>;
```

### Disable copy
- description: Set `disableCopy` to hide the copy button (for `singleline` / `multiline`) or render `inline` code as static, non-interactive text.
- example:
```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
- description: The copy action writes the displayed `code` to the clipboard by default. Use `copyText` to copy something different from what's shown.
- example:
```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
- description: `onCopy` fires after a successful clipboard write and receives the copied value.
- example:
```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
- description: Surface the package install command at the top of documentation.
- example:
```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
- description: Show a copy-ready quick-start block.
- example:
```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
- description: Use the `inline` variant to mark up specific text without breaking the flow.
- example:
```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
- description: Pair it with a `Card` to present an install or setup step as a self-contained block.
- example:
```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
- description: Drop an inline snippet into a `SectionHelper` to call out an exact command inside a tip.
- example:
```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
- description: Use a `FormField` label to present a copyable, read-only value such as an API key or ID.
- example:
```jsx
<FormField label="API key">
  <CodeSnippet
    code="wix_api_key_8f3a2b9c"
    variant="singleline"
    copyTooltipText="Copy API key"
    copiedTooltipText="Copied"
  />
</FormField>;
```
