Components

Shiki

Asynchronous syntax highlighting with Shiki, language options, and line numbers.

Props

Native attributes and event handlers are forwarded to the underlying pre element unless handled by the component.

PropTypeDefaultDescription
children Snippet undefined Content snippet rendered by the component.
class string '' Tailwind classes merged with the theme and variants.
code string '' Source text to highlight and copy.
element HTMLPreElement | null null Bindable reference to the underlying DOM element.
html string '' Bindable highlighted HTML output.
inTransition TransitionProps undefined Overrides the opening transition.
isLineNumbersVisible boolean true Shows line numbers in highlighted code.
isLoading boolean true Bindable highlighting loading state.
isVisible boolean true Bindable visibility state.
options Partial<CodeToHastOptions<BundledLanguage, BundledTheme>> undefined Shiki language, color theme, and transformer options.
outTransition TransitionProps undefined Overrides the closing transition.
theme Theme global theme Optional local theme override.
transition TransitionProps [noopTransition, {}] A Svelte transition function and its options.
variants string[] [] Local variant names or theme references such as button.base.

Default usage

Import Shiki from sveltewind/components. This example shows its default styling in a usable context.

Loading...
+page.svelte
Loading...

Examples

Theme variants

Every variant available for Shiki in the built-in themes is shown below.

compact — Apply the compact variant.

Loading...
+page.svelte
Loading...

wrap — Apply the wrap variant.

Loading...
+page.svelte
Loading...

scrollable — Apply the scrollable variant.

Loading...
+page.svelte
Loading...

Class overrides

Apply rounded-xl border border-primary-500/40 p-4 locally.

Loading...
+page.svelte
Loading...

Props and behavior

Bind isVisible and toggle it with a button to control whether the component is rendered.

Loading...
+page.svelte
Loading...

Content and values

Provide different code values.

Loading...
+page.svelte
Loading...

Hide line numbers

Disable line numbers while keeping language and color-theme options.

Loading...
+page.svelte
Loading...