# Code — SvelteKit UI

Package: sveltekit-ui 1.1.94

Page: https://www.sveltekit-ui.com/components/code

Category: Data & content

renders preformatted code content with a copy button

Public component import: `Code`

Public manager import: `create_code_manager`

## Usage

```svelte
<script>
  // Import the shared stylesheet once in your application's root layout.
  import "sveltekit-ui/style.css"
  import { Code, create_code_manager } from "sveltekit-ui"

  const manager = create_code_manager({
    language: "javascript",
    content: "const greeting = 'Hello, Svelte!'",
  })
</script>

<Code {manager} />
```

## Configuration

### `content`

- type: any
- default: null
- description: the code content to display, can be string or object

### `language`

- type: string
- default: null
- description: optional label indicating the code language

## Methods

### `init()`

- description: initializes the copy button manager
- parameters:
  - config: object
- returns: void

## Returned state

### `id`

- type: string
- description: unique id for this code block instance

### `copy_button_manager`

- type: object
- description: button manager configured to copy the code content to clipboard

### `language`

- type: string
- description: the language label for this code block

### `content`

- type: any
- description: the displayed code content
