CodeShowcase
CodeShowcaseCode and result Pair a code block with its visible result and the context needed to understand both.
Landing & pricingCode and its result
Write a normal fenced code block in the default slot. ts-ssg highlights it automatically; the result slot renders the matching component.
Semantic status
One component, one clear message.
<Badge tone="success">Ready</Badge> Compare the composition, then open its source tab to adapt it.
<CodeShowcase
eyebrow="A SMALL EXAMPLE"
title="Semantic status"
summary="One component, one clear message."
language="MDX"
resultTitle="Rendered result"
resultMeta="Live component"
tone="accent"
>
```html
<Badge tone="success">Ready</Badge>
```
<template #result>
<Badge tone="success">Ready</Badge>
</template>
</CodeShowcase> A focused code note
Omit resultTitle and resultMeta when a result panel is unnecessary.
A named value
const releaseName = 'Preview' <CodeShowcase title="A named value" language="TypeScript" variant="outline">
<pre><code>const releaseName = 'Preview'</code></pre>
</CodeShowcase> All ten semantic tones
The same composition in every semantic tone. Child tones are explicit where the composition owns them, including navigation actions.
neutral A small building block
<Badge>Ready</Badge> accent A small building block
<Badge>Ready</Badge> feature A small building block
<Badge>Ready</Badge> secondary A small building block
<Badge>Ready</Badge> custom A small building block
<Badge>Ready</Badge> ghost A small building block
<Badge>Ready</Badge> info A small building block
<Badge>Ready</Badge> success A small building block
<Badge>Ready</Badge> warning A small building block
<Badge>Ready</Badge> danger A small building block
<Badge>Ready</Badge> Switch the site theme to compare the same samples in both palettes.
All eighteen visual variants
Every supported variant is shown in accent, including none. Variant controls the outer treatment; nested content may use its own treatment.
solid surface A small building block
<Badge>Ready</Badge> surfaceAlt A small building block
<Badge>Ready</Badge> spotlight A small building block
<Badge>Ready</Badge> glass A small building block
<Badge>Ready</Badge> flat A small building block
<Badge>Ready</Badge> flatAlt A small building block
<Badge>Ready</Badge> flatSolid outlineFill outline A small building block
<Badge>Ready</Badge> subtle A small building block
<Badge>Ready</Badge> subtleBtn A small building block
<Badge>Ready</Badge> link A small building block
<Badge>Ready</Badge> sheen underline A small building block
<Badge>Ready</Badge> rail bracket A small building block
<Badge>Ready</Badge> none A small building block
<Badge>Ready</Badge> Switch the site theme to compare the same samples in both palettes.
Result panel conditions
Code onlyA named value
No result panel needed.
const status = 'ready' Result title onlyStatus label
<Badge>Ready</Badge> Result metadata onlyInline status
<Badge>Ready</Badge> Either resultTitle or resultMeta enables the result slot. language is a visible badge; syntax highlighting comes from MDX fenced code.
Feature map
| Public feature | Visible example |
|---|---|
| tone, variant | Complete galleries above, with all supported values visible together. |
| eyebrow, title, summary | The original code-and-result example introduces the purpose of the snippet. |
| language | MDX and TypeScript badges label the snippets; the title-only result sample omits the language badge. |
| resultTitle, resultMeta | Compare code-only, title-only result, metadata-only result, and the original result with both fields. |
| Default and result slots | The default slot holds code; the named result slot holds live rendered content. A result heading or metadata is required to show that panel. |
| Native attributes and events | Pass attributes through the root; keyboard behavior belongs to the composed native controls. |
This component exposes tone and variant, but no variantMode. Style individual child components explicitly when their appearance should match.
Behavior and accessibility
The language prop is a badge, not a syntax-highlighting engine. ts-ssg highlights fenced code in MDX automatically. A result slot is rendered only when resultTitle or resultMeta is present. Keep results keyboard-accessible when they contain controls.
API reference
CodeShowcase contract
Props below are the public template API. RefOrValue accepts a literal or a reactive ref; bind refs with a colon-prefixed attribute. Native attributes and events can be passed through the component root.
eyebrow
RefOrValue<string> - Default
not set
Short context above the heading, such as a category or release label.
title
RefOrValue<string> - Default
not set
Visible heading. Choose a short title that identifies the content or task.
summary
RefOrValue<string> - Default
not set
A concise explanation beneath the heading.
language
RefOrValue<string> - Default
not set
Language label displayed in a Badge. It does not transform source text.
resultTitle
RefOrValue<string> - Default
not set
Result heading. Setting this or resultMeta enables the result panel.
resultMeta
RefOrValue<string> - Default
not set
Result status or metadata badge. Setting this or resultTitle enables the result panel.
tone
RefOrValue<SemanticTone> - Default
inherited
Semantic intent: neutral, accent, secondary, info, success, warning, danger, feature, custom or ghost. The active skin supplies the colors.
variant
RefOrValue<ComponentVariant> - Default
surface
Visual treatment. Accepts solid, surface, surfaceAlt, spotlight, glass, flat, flatAlt, flatSolid, outlineFill, outline, subtle, subtleBtn, link, sheen, underline, rail, bracket or none.
Composition
Default slot: code or other explanatory content. result: rendered example. Register defineCodeShowcaseComponent with Panel, Flex, SectionHeader and Badge.