Basic

A .code-block around a pre. The copy button sits in the top right corner.

npm install @tabler/core
pnpm add @tabler/core
yarn add @tabler/core

With header

A title or a file name and a language label. The copy button moves into the header.

package.json JSON
{
  "name": "my-dashboard",
  "dependencies": {
    "@tabler/core": "^1.6.0"
  }
}

Line numbers and highlighted lines

Add .code-block-numbered and mark the lines to point out with .code-line-highlight.

share.js JavaScript
import { Clipboard } from '@tabler/core'

const button = document.querySelector('#share')

const clipboard = Clipboard.getOrCreateInstance(button, {
  text: window.location.href,
})

button.addEventListener('copied.bs.clipboard', () => {
  console.log('Link copied')
})

clipboard.copy()

Max height

Add .code-block-scroll to scroll long code vertically. Change the height with --tblr-code-block-max-height.

share.js JavaScript
import { Clipboard } from '@tabler/core'

const button = document.querySelector('#share')

const clipboard = Clipboard.getOrCreateInstance(button, {
  text: window.location.href,
})

button.addEventListener('copied.bs.clipboard', () => {
  console.log('Link copied')
})

clipboard.copy()

Header variants

The header can hold only a title, only a language, or both.

Terminal
npm run build
CSS
display: grid;
Deploy Shell
git push origin main

Markup

Any text works, also HTML. The copy button copies the code as written.

clipboard.html HTML
<button type="button" class="btn" data-bs-toggle="clipboard" data-bs-text="https://tabler.io/">
  <span class="clipboard-label">Copy link</span>
  <span class="clipboard-feedback">Link copied</span>
</button>

Long lines

Lines that do not fit scroll horizontally with the themed scrollbar. The page does not scroll.

Create a deployment Shell
curl -X POST https://api.example.com/v1/projects/42/deployments -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" -d '{"branch": "main", "environment": "production"}'

Without copy button

Set copy={false} on the component, or leave the button out of the markup.

npm install @tabler/core