Code.svelte

view source

Declarations
#

Code
#

Code.svelte view source

accepts children

import Code from '@fuzdev/fuz_code/Code.svelte';

content?

The source code to style.

type string
optional

dangerous_raw_html?

type string
optional

lang?

Language identifier (e.g. 'ts', 'css', 'html', 'json', 'svelte', 'md'). Selects the registered lexer and sets the data-lang attribute. null or an unregistered id disables styling (content renders as plain text, and an unregistered id logs an error in DEV); undefined falls back to the default ('svelte').

type string | null
optional default 'svelte'

inline?

Whether to render as inline code instead of a block.

type boolean
optional default false

wrap?

Whether to wrap long lines in block code (white-space: pre-wrap instead of pre). Wraps at whitespace — long unbroken tokens (URLs, hashes) still scroll horizontally. Ignored for inline code.

type boolean
optional default false

nomargin?

Whether to disable the default margin-bottom on block code (var(--space_lg) when not :last-child).

type boolean
optional default false

syntax_styler?

Custom SyntaxStyler instance, e.g. with different languages registered.

optional default syntax_styler_global

children?

Optional snippet to customize how the styled markup is rendered. Receives the generated HTML string as a parameter.

type Snippet<[]> & Snippet<[markup: string]>
optional

external types

SvelteHTMLElements['code']

Depends on
#