bg-color (attribute) |
Background color of the view box. Accepts any CSS color value or custom property. |
<view-code bg-color="var(--light)"></view-code>
|
title-bg-color (attribute) |
Background color for the title bar. |
<view-code title-bg-color="#ccc"></view-code>
|
background-color (attribute) |
Background color of the code area (maps to --code-bg). Default: var(--light). |
<view-code background-color="#1e1e1e"></view-code>
|
color (attribute) |
Foreground (text) color of the code area (maps to --code-fg). Default: var(--dark). |
<view-code color="#d4d4d4"></view-code>
|
width (attribute) |
Initial width of the view box (any CSS length: ch, rem, px). Overridden by click-to-resize after the first click. |
<view-code width="50ch"></view-code>
|
height (attribute) |
Height of the code area. Defaults to auto (grows with content). |
<view-code height="20rem"></view-code>
|
overflow-x (attribute) |
Horizontal overflow policy for the code area. Default: auto. |
<view-code overflow-x="scroll"></view-code>
|
code-padding (attribute) |
Padding inside the code box. Default: 0.75rem 1rem. |
<view-code code-padding="0.5rem 0.75rem"></view-code>
|
font-family (attribute) |
Font family applied to the visible code element. |
<view-code font-family="JetBrains Mono"></view-code>
|
font-size (attribute) |
Font size applied to the visible code element and inner <code>. |
<view-code font-size="0.9rem"></view-code>
|
highlight (attribute) |
Set to "prism" to use Prism.js syntax highlighting. Requires a <pre slot="code"><code> structure in the light DOM. |
<view-code highlight="prism"></view-code>
|
language (attribute) |
Prism language ID (e.g., javascript, cpp, rust). Adds language-* classes to the slotted <pre> and <code>. |
<view-code highlight="prism" language="cpp"></view-code>
|
trim (attribute) |
Boolean. Removes one leading and one trailing blank line from code content. Works in both default and Prism modes. |
<view-code trim></view-code>
|
normalize-indent (attribute) |
Boolean. Strips the minimum common leading whitespace from all non-empty lines, removing page-level indentation. |
<view-code normalize-indent></view-code>
|
step-px (attribute) |
Pixels added or removed per click. Default: 40. |
<view-code step-px="60"></view-code>
|
min-width (attribute) |
Minimum view width in pixels when shrinking. Default: 240. |
<view-code min-width="300"></view-code>
|
Slot: (default) |
Caption text rendered in the title bar above the code. |
<view-code>
Figure 1. My Code
</view-code>
|
Slot: code |
Code content. In default mode, accepts text nodes or <template>. In Prism mode, requires <pre><code class="language-*">. |
<view-code highlight="prism" language="rust">
Title
<pre slot="code">
<code class="language-rust">
fn main() {}
</code>
</pre>
</view-code>
|
| Click code (behavior) |
Widens the view by step-px per click, measured from the width at first click. |
// user clicks code panel → width grows by step-px
|
| Click title (behavior) |
Narrows the view by step-px per click, clamped to min-width. |
// user clicks title bar → width shrinks by step-px
|
CSS parts: view, title |
Exposed via part attribute for external styling with ::part(). |
view-code::part(title) {
font-style: italic;
}
|
| Events |
No custom events are dispatched. Width changes and rendering happen internally. |
// no custom events in current build
|