ki-markdown
@kimen/elements/ki-markdown- Source
- Agent reference
Use Markdown for a formatted answer or a note written by a person or a model.
<ki-markdown heading-offset="1"># Validation checklist
- [x] Give each field a label- [ ] Explain how to fix each error
> [!NOTE]> Put the error beside the field.</ki-markdown>Provide source
Set src-text for a string supplied as an attribute. In JavaScript, assign
srcText or update the element’s direct text nodes. An explicit srcText
value takes precedence, including an empty string. Escape angle brackets when
writing source into an HTML document so the browser passes them as text.
Set streaming while appending chunks to the source and clear it when the
answer ends. An open code fence stays a code block as lines arrive. A table
appears when its delimiter is complete and its last row can fill in over time.
Formatting and destinations
The supported Markdown subset includes headings, paragraphs, emphasis,
strikethrough, inline and fenced code, links, opt-in images, ordered and
unordered lists, task items, blockquotes, tables and hard breaks.
Task checkboxes show their state and stay disabled. Fenced code uses
CodeBlock and its language label. Tables have
native column headings. A blockquote that starts with [!NOTE] uses
Note.
The default heading offset of 2 renders a top-level Markdown heading as
h3. Set heading-offset from 0 to 5 to fit the surrounding page outline.
The deepest rendered level is h6.
HTML in the source is shown as text. Links and enabled images accept HTTP,
HTTPS and relative references. A guarded surface can restrict both to its
configured absolute origins. Rejected destinations leave the matching text
visible. Set allow-images to let images load. Cross-origin links use
Link and include its new-tab announcement.
Register child elements
The package loader registers Markdown, Link, CodeBlock and Note. With direct imports or a framework wrapper, register the child elements your content uses before rendering Markdown.
import { defineCustomElement as defineCodeBlock } from '@kimen/elements/ki-code-block';import { defineCustomElement as defineLink } from '@kimen/elements/ki-link';import { defineCustomElement as defineNote } from '@kimen/elements/ki-note';import { defineCustomElement as defineMarkdown } from '@kimen/elements/ki-markdown';
defineCodeBlock();defineLink();defineNote();defineMarkdown();With a framework wrapper, use the first three registrations. The wrapper registers Markdown.
API reference
When to use: Show a formatted reply, readme excerpt or progressively received text from a person or model.
When not to use: Present an editable document or apply trusted authored HTML. Use native markup for structured page content.
Properties & attributes
| Attribute | Property | Type | Default | Description |
|---|---|---|---|---|
allow-images | allowImages | boolean | false | Render Markdown images that pass the URL policy. Otherwise show their alternative text. |
heading-offset | headingOffset | number | 2 | Add zero through five levels to source headings. The output stops at level six. Invalid values use two. |
src-text | srcText | string | undefined | – | Markdown source. A supplied value, including an empty string, takes precedence over the default text slot. |
streaming | streaming | boolean | false | Keep established blocks mounted while an answer grows. Turn it off when the source is complete. |
Slots
| Slot | Description |
|---|---|
| (default) | Literal Markdown source. Set a text node or escape markup when writing HTML. |
CSS parts
| Part | Description |
|---|---|
content | Box containing the formatted blocks. |
CSS custom properties
The public styling contract of ki-markdown: reassign these tokens at :root or on a subtree — never override internals.
| Token | Description |
|---|---|
--ki-corner-inline | Small radius for an outline around inline content. |
--ki-density-space-scale | Multiplies every scaled container padding and gap (card, dialog, alert, list, list item, select listbox, tab panel, tooltip). |
--ki-focus-ring-color | Colour of the keyboard focus ring every focusable component draws: 3:1 or more against the page in every theme and scheme. |
--ki-focus-ring-width | Thickness of the keyboard focus ring every focusable component draws (its outline). One token instead of one per component, so a mode or a theme changes every ring at once. |
--ki-layout-spacing-5xl | The 5xl spacing step for a stack or grid gap. |
--ki-layout-spacing-xs | The xs spacing step for a stack or grid gap. |
--ki-markdown-backdrop-filter | Complete backdrop filter for the answer surface. |
--ki-markdown-bg | Answer surface backing. It defaults to transparent so the enclosing surface shows through. |
--ki-markdown-bg-image | Optional image over the answer's solid backing. |
--ki-markdown-block-gap | Spacing between Markdown blocks at standard density. |
--ki-markdown-fg | Ink for prose and headings. |
--ki-markdown-heading-family | Typeface for Markdown headings. |
--ki-markdown-inline-code-backdrop-filter | Complete backdrop filter for inline code. |
--ki-markdown-inline-code-bg | Solid backing of an inline code span. |
--ki-markdown-inline-code-bg-image | Optional image over the inline code backing. |
--ki-markdown-inline-code-fg | Ink for source within an inline code span. |
--ki-markdown-muted-backdrop-filter | Complete backdrop filter for quotes and table headings. |
--ki-markdown-muted-bg | Backing of quotes and table headings. |
--ki-markdown-muted-bg-image | Optional image over the muted backing. |
--ki-markdown-muted-fg | Ink for quotes and table headings, strengthened under more contrast. |
--ki-markdown-quote-border | Logical start rule of a quotation and the ink of a thematic divider. |
--ki-outline-low-em | semantic color for outline low em. |
--ki-spacing-action-hairline | Width of the frame and divider in an action surface. |
--ki-typography-family-body | semantic font family for typography family body. |
--ki-typography-family-mono | semantic font family for typography family mono. |
--ki-typography-line-height-body-2 | semantic dimension for typography line height body 2. |
--ki-typography-line-height-heading-1 | semantic dimension for typography line height heading 1. |
--ki-typography-line-height-heading-2 | semantic dimension for typography line height heading 2. |
--ki-typography-line-height-title-1 | semantic dimension for typography line height title 1. |
--ki-typography-line-height-title-2 | semantic dimension for typography line height title 2. |
--ki-typography-size-body-1 | semantic dimension for typography size body 1. |
--ki-typography-size-body-2 | semantic dimension for typography size body 2. |
--ki-typography-size-caption-2 | semantic dimension for typography size caption 2. |
--ki-typography-size-heading-1 | semantic dimension for typography size heading 1. |
--ki-typography-size-heading-2 | semantic dimension for typography size heading 2. |
--ki-typography-size-title-1 | semantic dimension for typography size title 1. |
--ki-typography-size-title-2 | semantic dimension for typography size title 2. |
--ki-typography-weight-body-medium | semantic font weight for typography weight body medium. |
--ki-typography-weight-body-semibold | semantic font weight for typography weight body semibold. |