skip section navigation

Codeblock

Codeblock displays literal source with syntax highlighting and a copy action. pass the source as a string so angle brackets and braces stay code rather than becoming part of your page.

reading-list.js
const readingList = ["The balcony garden"];
console.log(readingList.length);

usage

svelte
<script>
	import { Codeblock } from '@ciabi/loafkit-ui';
	const code = `const readingList = ["The balcony garden"];
console.log(readingList.length);`;
</script>

<Codeblock {code} language="javascript" title="reading-list.js" />

API reference

Codeblock

Component
code
Default: ''

literal source to highlight and copy.

language
Default: 'plaintext'

syntax-highlighting language.

title
Default: 'code'

label in the code panel header.

class
Default: ''

extra classes on the component root.

style

inline styles on the component root.