Skip to content

Markdown Text

Markdown Text components are Display Fields used to render structured and formatted content as HTML. They are non-interactive and purely informational. Use them when you need to display rich content such as headings, lists, bold text, links, or any other markdown-formatted text — as opposed to alert, which is designed for short status messages.

markdowntext.ts
import { golemForm } from '@golemui/gui-shared';
export default golemForm().create({
form: [
{
uid: 'markdowntext_demo',
kind: 'display',
type: 'markdownText',
props: {
md: '## Welcome
This is a **markdownText** display widget. It renders _markdown_ content as formatted HTML.
- Use it for structured text
- Use it for rich content display
- Use it for formatted instructions',
},
},
],
});

The Markdown Text component requires a markdown parser to render formatted HTML. Since the parser is a third-party dependency, it is not bundled with the component. Instead, you provide it at the form level via the dependencies property, keeping the core library decoupled from any specific parser.

Pass dependencies as a property on the form component itself, not inside the widget’s props:

import snarkdown from 'snarkdown';
import { Dependencies } from '@golemui/gui-shared';
const deps: Dependencies = {
markdown: {
parse: (md: string) => snarkdown(md),
},
};
<GolemForm
formDef={formDef}
data={formData}
dependencies={deps}
...
/>

Markdown Text can be styled as explained in the Styling Guide.

The following CSS custom properties control the visual appearance of rendered markdown content. Override them to match your design system.

CSS VariableDescription
--gui-md-text-colorBase text color
--gui-md-line-heightBase line height
--gui-md-heading-colorColor for h1–h6 headings
--gui-md-heading-weightFont weight for headings
--gui-md-link-colorLink text color
--gui-md-link-hover-colorLink color on hover
--gui-md-blockquote-bgBlockquote background
--gui-md-blockquote-border-colorBlockquote left border color
--gui-md-blockquote-colorBlockquote text color
--gui-md-code-bgBackground for inline code and code blocks
--gui-md-code-colorText color for inline code and code blocks
--gui-md-code-radiusBorder radius for inline code
--gui-md-hr-colorColor of horizontal rules

All tokens reference semantic tokens from the design system and adapt automatically in dark mode. See the full reference in Design Tokens — Markdown Text.

Use these props to customize your Markdown Text component.

proptypedescription
mdstringRequired. The markdown string to render