Docs Components Uncategorized

Markdown

React example follows below.
ts
import { Markdown } from "@grassroot/ui-react";
const source = `## Release notes
The renderer keeps **structure** and \`code\` safe.
> [!NOTE]
> This callout is parsed into a semantic render part.
- [x] CommonMark and GFM
- [ ] Editor round-trip
| Layer | Responsibility |
| --- | --- |
| Core | AST and diagnostics |
| Adapter | Framework markup |
[^1]: Footnotes stay addressable after rendering.`;
export default function MarkdownDemo() {
return <Markdown source={source} options={{ gfm: true, footnotes: true, callouts: true }} />;
}
ts
<script setup lang="ts">
import { Markdown } from "@grassroot/ui-vue";
const source = `## Release notes
The renderer keeps **structure** and \`code\` safe.
> [!NOTE]
> This callout is parsed into a semantic render part.
- [x] CommonMark and GFM
- [ ] Editor round-trip
| Layer | Responsibility |
| --- | --- |
| Core | AST and diagnostics |
| Adapter | Framework markup |
[^1]: Footnotes stay addressable after rendering.`;
const options = { gfm: true, footnotes: true, callouts: true };
</script>
<template>
<Markdown :source="source" :options="options" />
</template>
ts
import { Component } from "@angular/core";
import { GrassrootMarkdown } from "@grassroot/ui-angular";
@Component({
selector: "app-markdown-demo",
standalone: true,
imports: [GrassrootMarkdown],
host: { style: "display: contents" },
template: `<grassroot-markdown [source]="source" [options]="options" />`,
})
export class MarkdownDemoComponent {
protected readonly source = `## Release notes
The renderer keeps **structure** and \`code\` safe.
> [!NOTE]
> This callout is parsed into a semantic render part.
- [x] CommonMark and GFM
- [ ] Editor round-trip
| Layer | Responsibility |
| --- | --- |
| Core | AST and diagnostics |
| Adapter | Framework markup |
[^1]: Footnotes stay addressable after rendering.`;
protected readonly options = { gfm: true, footnotes: true, callouts: true };
}
export default MarkdownDemoComponent;
ts
<script lang="ts">
import { Markdown } from "@grassroot/ui-svelte";
const source = `## Release notes
The renderer keeps **structure** and \`code\` safe.
> [!NOTE]
> This callout is parsed into a semantic render part.
- [x] CommonMark and GFM
- [ ] Editor round-trip
| Layer | Responsibility |
| --- | --- |
| Core | AST and diagnostics |
| Adapter | Framework markup |
[^1]: Footnotes stay addressable after rendering.`;
const options = { gfm: true, footnotes: true, callouts: true };
</script>
<Markdown {source} {options} />
ts
/** @jsxImportSource solid-js */
import { Markdown } from "@grassroot/ui-solid";
const source = `## Release notes
The renderer keeps **structure** and \`code\` safe.
> [!NOTE]
> This callout is parsed into a semantic render part.
- [x] CommonMark and GFM
- [ ] Editor round-trip
| Layer | Responsibility |
| --- | --- |
| Core | AST and diagnostics |
| Adapter | Framework markup |
[^1]: Footnotes stay addressable after rendering.`;
export default function MarkdownDemo() {
return <Markdown source={source} options={{ gfm: true, footnotes: true, callouts: true }} />;
}

Installation

API Reference

Import

import { Markdown } from "@grassroot/ui-react";

Props

Prop
Type
Default
Requirement
source
string | undefined
optional
ast
import("@grassroot/ui-headless-core").MarkdownDocument | undefined
optional
options
import("@grassroot/ui-headless-core").ParseOptions | undefined
optional
components
Partial<Record<import("@grassroot/ui-headless-core").MarkdownNodeType, React.ComponentType<MarkdownComponentProps>>> | undefined
optional
code
Readonly<Record<string, React.ComponentType<MarkdownComponentProps>>> | undefined
optional
highlight
((code: string, lang: string | undefined) => readonly import("@grassroot/ui-headless-core").HighlightToken[]) | undefined
optional
dir
"auto" | "ltr" | "rtl" | undefined
optional
className
string | undefined
optional
Prop
source
Type
string | undefined
Default
Requirement
optional
Prop
ast
Type
import("@grassroot/ui-headless-core").MarkdownDocument | undefined
Default
Requirement
optional
Prop
options
Type
import("@grassroot/ui-headless-core").ParseOptions | undefined
Default
Requirement
optional
Prop
components
Type
Partial<Record<import("@grassroot/ui-headless-core").MarkdownNodeType, React.ComponentType<MarkdownComponentProps>>> | undefined
Default
Requirement
optional
Prop
code
Type
Readonly<Record<string, React.ComponentType<MarkdownComponentProps>>> | undefined
Default
Requirement
optional
Prop
highlight
Type
((code: string, lang: string | undefined) => readonly import("@grassroot/ui-headless-core").HighlightToken[]) | undefined
Default
Requirement
optional
Prop
dir
Type
"auto" | "ltr" | "rtl" | undefined
Default
Requirement
optional
Prop
className
Type
string | undefined
Default
Requirement
optional

Import

import { Markdown } from "@grassroot/ui-vue";

Props

Prop
Type
Default
Requirement
source
string | undefined
""
optional
ast
MarkdownDocument | undefined
optional
options
ParseOptions | undefined
optional
components
Partial<Record<MarkdownNodeType, Component>> | undefined
optional
code
Readonly<Record<string, Component>> | undefined
optional
highlight
((code: string, lang: string | undefined) => readonly HighlightToken[]) | undefined
optional
dir
"ltr" | "rtl" | "auto" | undefined
optional
className
string | undefined
optional
Prop
source
Type
string | undefined
Default
""
Requirement
optional
Prop
ast
Type
MarkdownDocument | undefined
Default
Requirement
optional
Prop
options
Type
ParseOptions | undefined
Default
Requirement
optional
Prop
components
Type
Partial<Record<MarkdownNodeType, Component>> | undefined
Default
Requirement
optional
Prop
code
Type
Readonly<Record<string, Component>> | undefined
Default
Requirement
optional
Prop
highlight
Type
((code: string, lang: string | undefined) => readonly HighlightToken[]) | undefined
Default
Requirement
optional
Prop
dir
Type
"ltr" | "rtl" | "auto" | undefined
Default
Requirement
optional
Prop
className
Type
string | undefined
Default
Requirement
optional

Import

import { Component } from "@angular/core";
import { GrassrootMarkdown } from "@grassroot/ui-angular";

Props

Prop
Type
Default
Requirement
source
string
""
optional
ast
MarkdownDocument
optional
options
ParseOptions
optional
components
Partial<Record<MarkdownNodeType, unknown>>
optional
code
Readonly<Record<string, unknown>>
optional
highlight
(code: string, lang: string | undefined) => readonly HighlightToken[]
optional
dir
"ltr" | "rtl" | "auto"
optional
className
string
optional
Prop
source
Type
string
Default
""
Requirement
optional
Prop
ast
Type
MarkdownDocument
Default
Requirement
optional
Prop
options
Type
ParseOptions
Default
Requirement
optional
Prop
components
Type
Partial<Record<MarkdownNodeType, unknown>>
Default
Requirement
optional
Prop
code
Type
Readonly<Record<string, unknown>>
Default
Requirement
optional
Prop
highlight
Type
(code: string, lang: string | undefined) => readonly HighlightToken[]
Default
Requirement
optional
Prop
dir
Type
"ltr" | "rtl" | "auto"
Default
Requirement
optional
Prop
className
Type
string
Default
Requirement
optional

Import

import { Markdown } from "@grassroot/ui-svelte";

Props

Prop
Type
Default
Requirement
source
string
""
optional
ast
MarkdownDocument
optional
options
ParseOptions
optional
components
Partial<Record<MarkdownNodeType, unknown>>
optional
code
Readonly<Record<string, unknown>>
optional
highlight
(code: string, lang: string | undefined) => readonly HighlightToken[]
optional
dir
"ltr" | "rtl" | "auto"
optional
className
string
optional
Prop
source
Type
string
Default
""
Requirement
optional
Prop
ast
Type
MarkdownDocument
Default
Requirement
optional
Prop
options
Type
ParseOptions
Default
Requirement
optional
Prop
components
Type
Partial<Record<MarkdownNodeType, unknown>>
Default
Requirement
optional
Prop
code
Type
Readonly<Record<string, unknown>>
Default
Requirement
optional
Prop
highlight
Type
(code: string, lang: string | undefined) => readonly HighlightToken[]
Default
Requirement
optional
Prop
dir
Type
"ltr" | "rtl" | "auto"
Default
Requirement
optional
Prop
className
Type
string
Default
Requirement
optional

Import

import { Markdown } from "@grassroot/ui-solid";

Props

Prop
Type
Default
Requirement
source
string
optional
ast
MarkdownAst
optional
options
MarkdownOptions
optional
components
HeadlessMarkdownProps["components"]
optional
code
HeadlessMarkdownProps["code"]
optional
highlight
HeadlessMarkdownProps["highlight"]
optional
dir
"ltr" | "rtl" | "auto"
optional
className
string
optional
Prop
source
Type
string
Default
Requirement
optional
Prop
ast
Type
MarkdownAst
Default
Requirement
optional
Prop
options
Type
MarkdownOptions
Default
Requirement
optional
Prop
components
Type
HeadlessMarkdownProps["components"]
Default
Requirement
optional
Prop
code
Type
HeadlessMarkdownProps["code"]
Default
Requirement
optional
Prop
highlight
Type
HeadlessMarkdownProps["highlight"]
Default
Requirement
optional
Prop
dir
Type
"ltr" | "rtl" | "auto"
Default
Requirement
optional
Prop
className
Type
string
Default
Requirement
optional