Markdown¶

A view that renders CommonMark/GitHub Flavored Markdown text natively. Supports headings, bold, italic, strikethrough, inline code, fenced code blocks, links, lists, blockquotes, task lists, tables, and images. The content property is reactive. Changing it triggers an immediate UI update.
Constructor¶
nib.Markdown(
content,
theme=None,
**modifiers,
)
Parameters¶
| Parameter | Type | Default | Description |
|---|---|---|---|
content |
str |
(required) | The Markdown string to render. |
theme |
str |
None |
Optional theme name. Options: "basic" (default), "gitHub", "docC". |
**modifiers |
Common view modifiers: padding, background, foreground_color, opacity, width, height, etc. |
Mutable Properties¶
| Property | Type | Description |
|---|---|---|
content |
str |
Get or set the Markdown text. Setting triggers a UI update. |
theme |
str |
Get or set the rendering theme. Setting triggers a UI update. |
Examples¶
Inline markdown¶

import nib
def main(app: nib.App):
app.title = "Changelog"
app.icon = nib.SFSymbol("text.document")
app.width = 340
app.build(
nib.VStack(
controls=[
nib.Text("1.2.0", font=nib.Font.HEADLINE),
nib.Markdown(
"**Highlights:** faster startup, a redesigned settings window "
"and `nib --version`. ~~Known crash on wake~~ fixed. "
"Update with `pip install -U pynib`, details in the "
"[release notes](https://edo.codeberg.page/nib/)."
),
],
spacing=8,
padding=20,
alignment=nib.Alignment.LEADING,
)
)
nib.run(main)
Reactive content¶

import nib
def main(app: nib.App):
app.title = "Pomodoro"
app.icon = nib.SFSymbol("timer")
app.width = 300
sessions = [2]
summary = nib.Markdown("")
def render():
done = sessions[0]
summary.content = f"Session **{done} of 4** done, " + (
"break in *25 min*." if done < 4 else "*well played*."
)
def finish():
sessions[0] = min(sessions[0] + 1, 4)
render()
render()
app.build(
nib.VStack(
controls=[summary, nib.Button("Finish session", action=finish)],
spacing=12,
padding=20,
)
)
nib.run(main)
Related¶
- Text
- TextEditor
- WebView: HTML content