Markdown¶

A view that renders CommonMark text natively. Supports headings, bold, italic, strikethrough, inline code, fenced code blocks, links, lists, blockquotes, horizontal rules and tables. Images and task lists are not drawn. The content property is reactive. Changing it triggers an immediate UI update.
Constructor¶
nib.Markdown(
content,
**modifiers,
)
Parameters¶
| Parameter | Type | Default | Description |
|---|---|---|---|
content |
str |
(required) | The Markdown string to render. |
**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. |
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.HorizontalAlignment.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", on_click=finish)],
spacing=12,
padding=20,
)
)
nib.run(main)
Related¶
- Text
- TextEditor
- WebView: HTML content