API Reference¶
Deck — Deck¶
- class montin.Deck(title, author='', date='', version='', theme='default', custom_css=None, fontsize_scale=1.0, self_contained=True, plugins=[], plugin_source='cdn', slide_defaults=SlideDefaults(nrows=1, ncols=1, row_heights=None, col_widths=None), cell_defaults=CellDefaults(overflow=True, copy_button=False, expand_button=False, transparent=False, halign='left', valign='top', fontscale=1.0), autosave=None, autosave_level='slide', size=None, scale_up=False, keep_aspect_ratio=True, show_sidebar=True, show_toolbar=True, sidebar_collapsed=False, sidebar_search=True, sidebar_search_scope='title', sidebar_collapsible_sections=True, preview_height=None, contents_folder=None, security=None)[source]¶
Bases:
objectMain container for a report deck.
- Parameters:
title (str) – The presentation title (required).
author (str) – The presentation author (optional).
date (str) – The presentation date (optional, defaults to today).
version (str) – The presentation version (optional).
theme (str)
custom_css (str | Path | None) – Optional path to a custom CSS file to include.
fontsize_scale (float) – Multiplier applied to every font in the presentation — slide content and the navigation chrome (sidebar, toolbar, TOC, lightbox) alike (default
1.0). Spacing and layout are unaffected. Per-cellfontscalecomposes on top of this.self_contained (bool) – Whether to produce a self-contained HTML file with embedded assets (default: True).
plugins (list[Plugin]) – Optional JS libraries to include, declared via the
Pluginscontainer, e.g.[Plugins.Plotly(), Plugins.Mermaid()](default:[]). Nothing is mandatory — declare only what you use.plugin_source (Literal['cdn', 'bundled']) – Default loading mode for every plugin that doesn’t set its own
source(default:'cdn').'bundled'embeds the libraries for a report that works fully offline. ASecurity(block_external=True)forces'bundled'.security (Security | None) – Security / privacy hardening for the output (CSP, SRI, no-referrer, Permissions-Policy, …).
None(default) applies light, always-safe hardening; passSecurity(...)to customise — notablyblock_external=Truefor a provably offline file.slide_defaults (SlideDefaults) – Global defaults for slides (default: SlideDefaults()).
cell_defaults (CellDefaults) – Global defaults for cells (default: CellDefaults()).
autosave (str | None) – Optional filename to autosave after each change. Use it when iteratively building a presentation to live-preview in a browser. If building a large presentation, consider not using autosave to avoid excessive writes.
autosave_level (Literal['slide', 'cell']) – Whether to autosave after each slide change or cell change (default: ‘slide’). Use ‘slide’ on presentations with many cells to avoid excessive writes. Only relevant if autosave is set to a filename.
size (tuple[int, int] | None) – Fixed slide dimensions in pixels, e.g.
(1366, 768). When set, slides become a fixed-size “stage” that is scaled with a CSS transform to fit the available area — every element (fonts, images, layout) scales together, just like a static PDF. WhenNone(default) the layout is fluid and fills the window (current behaviour).scale_up (bool) – When
sizeis set, allow scaling beyond the native dimensions to fill larger screens. WhenFalse(default) the stage never grows past 1:1 — it only shrinks on smaller windows.keep_aspect_ratio (bool) – When
sizeis set andTrue(default), the stage scales uniformly and is letterboxed. WhenFalsethe stage stretches to fill both dimensions independently (distorts content).show_sidebar (bool) – Render the slide-navigation sidebar (default
True). Set toFalsefor clean single-slide / embeddable files.show_toolbar (bool) – Render the bottom navigation toolbar (default
True). Set toFalsefor clean single-slide / embeddable files.sidebar_collapsed (bool) – Start with the sidebar collapsed (default
False). The sidebar can still be toggled open via the toolbar button or theBkey. Ignored whenshow_sidebarisFalse. A previously remembered toggle state (fromlocalStorage) takes precedence over this default.sidebar_search (bool) – Render a regex search box at the top of the sidebar that live-filters slides (default
True). Ignored whenshow_sidebarisFalse.sidebar_search_scope (Literal['title', 'title_subtitle', 'content']) – What the search regex matches against (default
'title').'title'matches the sidebar title only;'title_subtitle'also matches the slide subtitle;'content'searches the slide’s full rendered text. Note: with'content', Plotly/Mermaid bodies are not searchable until they have rendered in the browser.sidebar_collapsible_sections (bool) – Show a caret on section items that folds/unfolds the slides under that section (default
True). Ignored whenshow_sidebarisFalse.preview_height (int | None)
contents_folder (str | Path | None)
Example:
deck = Deck( title="Q3 Report", author="J. Smith", theme="default", plugins=[Plugins.MathJax(), Plugins.Plotly()], slide_defaults=SlideDefaults(nrows=2, ncols=2), cell_defaults=CellDefaults(expand_button=True), ) deck.add_title("Q3 Report") slide = deck.add_slide("Results") slide.add_metric(value=98.7, label="Efficiency") deck.write("q3-report")
- add_title(title, subtitle='', notes='', title_id=None, notebook_unique=False)[source]¶
Add the cover/title slide.
- Parameters:
title (str) – Main heading.
subtitle (str) – Optional secondary text.
notes (str) – Presenter notes (not rendered on the slide).
title_id (Hashable | None) – Stable identifier, like
slide_idonadd_slide. Re-running with the sametitle_idreplaces the title slide in place instead of appending a duplicate — useful in notebooks.notebook_unique (bool)
- Returns:
The newly created
Slide.- Return type:
- add_section(title, subtitle='', level=1, add_to_toc=True, show_toc=True, section_id=None, notebook_unique=False)[source]¶
Add a section-divider slide.
- Parameters:
title (str) – Section heading.
subtitle (str) – Optional secondary text below the heading.
level (int) – Hierarchy depth (1 = top-level, 2 = sub-section, …). Higher levels are indented and visually dimmed in the sidebar.
add_to_toc (bool) – Whether to include this section in TOC slides and inline section TOCs (default
True).show_toc (bool) – Whether to render an inline TOC on this slide highlighting the current section (default
True).section_id (Hashable | None) – Stable identifier, like
slide_idonadd_slide. Re-running with the samesection_idreplaces the section (and its TOC entry) in place instead of appending a duplicate.notebook_unique (bool)
- Returns:
The newly created
Slide.- Return type:
- add_toc(title='Table of Contents', auto=True, toc_id=None, notebook_unique=False)[source]¶
Add a Table of Contents slide.
The TOC is always populated at
write()time so it reflects all sections in the deck regardless of call order.- Parameters:
title (str) – Slide heading shown in the header bar.
auto (bool) – When
True(default), the TOC is built automatically from alladd_section()calls. WhenFalsethe slide is rendered with an empty TOC.toc_id (Hashable | None) – Stable identifier, like
slide_idonadd_slide. Re-running with the sametoc_idreplaces the TOC slide in place instead of appending a duplicate.notebook_unique (bool)
- Returns:
The newly created
Slide.- Return type:
- add_slide(title, subtitle='', nrows=<UNSET>, ncols=<UNSET>, row_heights=<UNSET>, col_widths=<UNSET>, notes='', slide_id=None, slide_defaults=None, cell_defaults=None, notebook_unique=False)[source]¶
Add a standard content slide with an
nrows x ncolscell canvas.- Parameters:
title (str) – Slide heading shown in the header bar.
subtitle (str) – Optional secondary heading shown below the title.
nrows (int) – Number of grid rows. Falls back to
slide_defaults.nrowsthenself.slide_defaults.nrowswhen omitted.ncols (int) – Number of grid columns. Same fallback chain as
nrows.row_heights (List[str,...]) – Explicit heights for each row (CSS values such as
"1fr"or200).Nonelets the grid distribute space evenly. Falls back through the defaults hierarchy when omitted.col_widths (List[str,...]) – Explicit widths for each column. Same semantics as
row_heights.notes (str) – Presenter notes attached to this slide (not rendered in the slide itself).
slide_id (Hashable | None) – Stable identifier for this slide. Auto-generated as
"slide-<n>"whenNone. RaisesDuplicateSlideErrorif the id is already in use.slide_defaults (SlideDefaults | None) – Per-call override for grid defaults. Takes precedence over
self.slide_defaultsbut is overridden by any explicitly suppliednrows/ncols/row_heights/col_widthsargument.cell_defaults (CellDefaults | None) – Per-call override for cell defaults. Takes precedence over ``self.cell_defaults`
notebook_unique (bool)
- Returns:
The newly created
Slide.- Return type:
- write(filename=None, open_browser=False)[source]¶
Trigger the Assembler, write
<filename>.html, and return the Path.- Parameters:
filename (str | Path | None)
open_browser (bool)
- Return type:
Path
- remove_slide(slide_id)[source]¶
Remove a slide by its ID.
- Parameters:
slide_id (Hashable)
- Return type:
None
- property sections: list[dict]¶
Read-only list of TOC-registered section metadata dicts.
Configuration¶
- class montin.SlideDefaults(nrows=1, ncols=1, row_heights=None, col_widths=None)[source]¶
Bases:
objectGrid layout defaults applied to every
add_slide()call.Any value set here acts as the fallback when the corresponding argument is omitted from
add_slide(). Per-call arguments always take precedence.- Parameters:
nrows (int)
ncols (int)
row_heights (list[int | str] | None)
col_widths (list[int | str] | None)
- nrows¶
Number of grid rows (default
1).- Type:
int
- ncols¶
Number of grid columns (default
1).- Type:
int
- row_heights¶
CSS height for each row (e.g.
["2fr", "1fr"]).Nonedistributes space evenly.- Type:
list[int | str] | None
- col_widths¶
CSS width for each column (e.g.
["300px", "1fr"]).Nonedistributes space evenly.- Type:
list[int | str] | None
- nrows: int = 1¶
- ncols: int = 1¶
- row_heights: list[int | str] | None = None¶
- col_widths: list[int | str] | None = None¶
- class montin.CellDefaults(overflow=True, copy_button=False, expand_button=False, transparent=False, halign='left', valign='top', fontscale=1.0)[source]¶
Bases:
objectVisual and behaviour defaults applied to every
add_*()cell method.Any value set here acts as the fallback when the corresponding argument is omitted from a cell-creation call. Per-call arguments always take precedence.
- Parameters:
overflow (bool)
copy_button (bool)
expand_button (bool)
transparent (bool)
halign (Literal['left', 'center', 'right'])
valign (Literal['top', 'middle', 'bottom'])
fontscale (float)
- overflow¶
Whether cell content is scrollable when it overflows (default
True).- Type:
bool
- copy_button¶
Show a copy-to-clipboard button on the cell (default
False).- Type:
bool
- expand_button¶
Show a fullscreen-expand button on the cell (default
False).- Type:
bool
- transparent¶
Render the cell without a background card (default
False).- Type:
bool
- halign¶
Horizontal alignment of cell content —
"left","center", or"right"(default"left").- Type:
Literal[‘left’, ‘center’, ‘right’]
- valign¶
Vertical alignment of cell content —
"top","middle", or"bottom"(default"top").- Type:
Literal[‘top’, ‘middle’, ‘bottom’]
- fontscale¶
Multiplier applied to the cell’s text size (default
1.0). Composes on top of the deck-widefontsize_scale.- Type:
float
- overflow: bool = True¶
- copy_button: bool = False¶
- expand_button: bool = False¶
- transparent: bool = False¶
- halign: Literal['left', 'center', 'right'] = 'left'¶
- valign: Literal['top', 'middle', 'bottom'] = 'top'¶
- fontscale: float = 1.0¶
Plugins¶
- class montin.Plugin(source=None, version=None, url=None)[source]¶
Bases:
objectBase class for an optional JS library. Use a
Pluginssubclass.- Parameters:
source (Literal['cdn', 'bundled'] | None)
version (str | None)
url (str | None)
- source¶
"cdn"to load from a content-delivery network,"bundled"to embed the library in the report (fully offline).None(default) inherits the deck-wideDeck(plugin_source=...)setting.- Type:
Literal[‘cdn’, ‘bundled’] | None
- version¶
Pin a specific library version.
Noneuses the version Montin vendors / knows the CDN URL for.- Type:
str | None
- url¶
A custom URL to load the library from instead of the default CDN — e.g. a company intranet mirror. Only used in
"cdn"mode.- Type:
str | None
- name¶
The library identifier (
"plotly","mermaid", …). Set by each subclass; not meant to be overridden.- Type:
ClassVar[str]
- source: Literal['cdn', 'bundled'] | None = None¶
- version: str | None = None¶
- url: str | None = None¶
- name: ClassVar[str] = ''¶
- class montin.Plotly(source=None, version=None, url=None)[source]¶
Bases:
PluginPlotly.js — required by
slide.add_plotly().- Parameters:
source (Literal['cdn', 'bundled'] | None)
version (str | None)
url (str | None)
- name: ClassVar[str] = 'plotly'¶
- class montin.Mermaid(source=None, version=None, url=None, theme='dark')[source]¶
Bases:
PluginMermaid — required by
slide.add_mermaid().- Parameters:
source (Literal['cdn', 'bundled'] | None)
version (str | None)
url (str | None)
theme (str)
- theme¶
Mermaid theme passed to
mermaid.initialize(e.g."dark","default","forest","neutral").- Type:
str
- theme: str = 'dark'¶
- name: ClassVar[str] = 'mermaid'¶
- class montin.Highlight(source=None, version=None, url=None, style='github-dark')[source]¶
Bases:
Pluginhighlight.js — required by
slide.add_code().- Parameters:
source (Literal['cdn', 'bundled'] | None)
version (str | None)
url (str | None)
style (str)
- style¶
The highlight.js stylesheet name (e.g.
"github-dark","github","monokai"). Selects which CSS theme is loaded.- Type:
str
- style: str = 'github-dark'¶
- name: ClassVar[str] = 'highlight'¶
- class montin.MathJax(source=None, version=None, url=None, output='svg')[source]¶
Bases:
PluginMathJax — renders LaTeX math in
slide.add_text().- Parameters:
source (Literal['cdn', 'bundled'] | None)
version (str | None)
url (str | None)
output (Literal['svg', 'chtml'])
- output¶
"svg"(default) renders math as SVG with the glyphs embedded in the library, so a bundled deck stays a single offline file."chtml"uses HTML+CSS with web fonts that are fetched at runtime — slightly nicer text selection, but not single-file offline.- Type:
Literal[‘svg’, ‘chtml’]
- output: Literal['svg', 'chtml'] = 'svg'¶
- name: ClassVar[str] = 'mathjax'¶
- class montin.Tabulator(source=None, version=None, url=None, theme='auto')[source]¶
Bases:
PluginTabulator — required by
slide.add_tabulator()(interactive tables).- Parameters:
source (Literal['cdn', 'bundled'] | None)
version (str | None)
url (str | None)
theme (Literal['auto', 'light', 'dark'])
- theme¶
which bundled stylesheet to use.
"auto"(default) follows the deck theme — the dark sheet for thedefault/darkthemes, the light sheet forlight. Force it with"light"/"dark".- Type:
Literal[‘auto’, ‘light’, ‘dark’]
- theme: Literal['auto', 'light', 'dark'] = 'auto'¶
- name: ClassVar[str] = 'tabulator'¶
Security¶
- class montin.Security(block_external=False, sri=True, no_referrer=True, noindex=False, permissions_policy=True, csp=None)[source]¶
Bases:
objectSecurity / privacy options for a report.
The default
Security()applies light, always-safe hardening (a no-referrer hint, a Permissions-Policy declaration, and integrity hashes on any CDN-loaded library). The strong guarantee — a report that provably makes no external request — is the opt-inblock_external.- Parameters:
block_external (bool)
sri (bool)
no_referrer (bool)
noindex (bool)
permissions_policy (bool | str)
csp (str | None)
- block_external¶
Hard offline guarantee. Embeds every library in the file, tells the browser (via a strict Content-Security-Policy) to refuse any external request, and then re-reads the finished HTML to prove not a single external URL remains — raising instead of writing if one does. Use for air-gapped / regulated environments where the report must provably phone home to nobody. Forces all plugins to
bundled(and errors if a plugin was explicitly set to"cdn").- Type:
bool
- sri¶
Tamper-check for CDN libraries. When a library loads from a CDN, the browser compares the downloaded file against a fingerprint baked into the page; if a hacked or man-in-the-middled CDN serves altered code, the fingerprint won’t match and the browser refuses to run it. No effect on bundled plugins.
- Type:
bool
- no_referrer¶
Don’t leak where the report came from. When the report is hosted and someone clicks a link in it, the browser won’t tell the destination site which report URL they came from — avoiding leaks of possibly-sensitive internal paths. (Opening from disk has no referrer anyway, so this only matters when the report is served.)
- Type:
bool
- noindex¶
Keep it out of search engines. If the report is hosted on the web, asks crawlers not to list it, so an internal report doesn’t surface on Google. No effect for a file opened from disk.
- Type:
bool
- permissions_policy¶
Declare no camera / microphone / location use.
Trueemits a sensible “all sensors off” policy, a string sets a custom one,Falseomits it. Caveat: browsers only enforce this when a server sends it as an HTTP header; opened straight from disk (file://) the<meta>form is ignored, so here it is a documented statement of intent that becomes a real control only when the report is served behind a header-setting host.- Type:
bool | str
- csp¶
Advanced. Supply your own Content-Security-Policy string to take full control of what the page may load. Overrides the policy Montin would generate.
- Type:
str | None
- block_external: bool = False¶
- sri: bool = True¶
- no_referrer: bool = True¶
- noindex: bool = False¶
- permissions_policy: bool | str = True¶
- csp: str | None = None¶
Slide¶
- class montin.core.slide.Slide(*, slide_id, title, subtitle, slide_type, nrows, ncols, row_heights, col_widths, notes, cell_defaults, plugin_names, parent, level=1, show_toc=False)[source]¶
Bases:
objectRepresents a slide with a CSS Grid canvas of
nrows x ncolscells.Do not instantiate directly — use the
add_*methods ofDeck.- Parameters:
slide_id (Hashable)
title (str)
subtitle (str)
slide_type (SlideType)
nrows (int)
ncols (int)
row_heights (list[int | str] | None)
col_widths (list[int | str] | None)
notes (str)
cell_defaults (Any)
plugin_names (frozenset[str])
parent (Deck)
level (int)
show_toc (bool)
- remove_cell(cell_id, _caller_is_cell_method=False)[source]¶
Remove a cell from the slide and free its grid positions.
- Parameters:
cell_id (Hashable) – The identifier of the cell to remove, as returned by the cell’s
cell_idattribute or used as a key incell_map._caller_is_cell_method (bool)
- Raises:
KeyError – If no cell with
cell_idexists on this slide.- Return type:
None
- add_text(content, *, markdown=True, col=None, row=None, colspan=1, rowspan=1, caption='', overflow=<UNSET>, copy_button=<UNSET>, expand_button=<UNSET>, transparent=<UNSET>, halign=<UNSET>, valign=<UNSET>, fontscale=<UNSET>, _params=None)[source]¶
Add a text cell to the slide.
Content is rendered as Markdown by default. Supports standard Markdown (headings, bold, italic, lists, code spans, links) and LaTeX math (
$...$/$$...$$) whenPlugins.MathJax()is declared on the deck.- Parameters:
content (str) – Text to display. Parsed as Markdown unless
markdown=False.markdown (bool) – If
True(default), rendercontentas Markdown. PassFalseto display plain text without parsing.col (int | None) – Grid column (1-based). Auto-placed when omitted.
row (int | None) – Grid row (1-based). Auto-placed when omitted.
colspan (int) – Number of grid columns to span (default
1).rowspan (int) – Number of grid rows to span (default
1).caption (str) – Caption text displayed below the cell.
overflow (bool) – Show a scrollbar instead of clipping content.
copy_button (bool) – Show a copy-to-clipboard button on the cell card.
expand_button (bool) – Show a fullscreen-expand button on the cell card.
transparent (bool) – If
True, the cell background is transparent.halign (str) – Horizontal alignment —
"left","center", or"right".valign (str) – Vertical alignment —
"top","middle", or"bottom".fontscale (float) – Multiplier for this cell’s text size (default
1.0). Composes on top of the deck-widefontsize_scale._params (Any)
- Returns:
The newly created and registered text cell.
- Return type:
- add_image(source, *, lightbox=True, to_webp=False, webp_quality=None, save_source=False, col=None, row=None, colspan=1, rowspan=1, caption='', overflow=<UNSET>, copy_button=<UNSET>, expand_button=<UNSET>, _params=None)[source]¶
Add an image to the slide.
Accepts a file path, URL, base64 data URI, or a matplotlib
Figure. Matplotlib figures are rendered to SVG (default) or WebP and embedded inline. Clicking the image opens a lightbox viewer by default.- Parameters:
source (str | Any) –
Image source. One of:
File path (
strorpathlib.Path) to a PNG/JPG/SVG/WebP.URL (
"https://...").Base64 data URI.
matplotlib.figure.Figure— rendered to SVG or WebP and embedded inline.
lightbox (bool) – If
True(default), clicking the image opens it in a fullscreen lightbox viewer.to_webp (bool) – Convert to WebP before embedding. Reduces file size for photographs; for matplotlib figures uses WebP instead of SVG.
webp_quality (int | None) – WebP quality level (1–100).
Noneuses the encoder’s default (~80).save_source (bool) – If
True, embed the original source file alongside the processed image so it can be recovered from the HTML.col (int | None) – Grid column (1-based). Auto-placed when omitted.
row (int | None) – Grid row (1-based). Auto-placed when omitted.
colspan (int) – Number of grid columns to span (default
1).rowspan (int) – Number of grid rows to span (default
1).caption (str) – Caption text displayed below the image.
overflow (bool) – Show a scrollbar on the cell instead of clipping.
copy_button (bool) – Show a copy-to-clipboard button on the cell card.
expand_button (bool) – Show a fullscreen-expand button on the cell card.
_params (Any)
- Returns:
MatplotlibCellwhensourceis a matplotlibFigure, otherwiseImageCell.- Return type:
ImageCell | MatplotlibCell
- add_table(data, *, separator='auto', index=False, col=None, row=None, colspan=1, rowspan=1, caption='', overflow=<UNSET>, copy_button=<UNSET>, expand_button=<UNSET>, _params=None)[source]¶
Add a static HTML table to the slide.
Renders a plain, non-interactive
<table>. For sortable, filterable, and paginated tables useadd_tabulatorinstead.- Parameters:
data (dict[str, Any] | list[list[Any]] | pd.DataFrame | str) –
Tabular data. Accepts:
dict[str, list]— keys = column headers, values = columns.list[list]— first sub-list is the header row.pandas.DataFrame.A CSV/TSV string.
A path to a CSV/TSV file.
separator (Literal['auto', ',', '\t']) – Field separator for string or file inputs.
"auto"(default) detects a tab in the first line; otherwise","or"\t".index (bool) – For pandas DataFrames only — if
True, include the index as the first column.col (int | None) – Grid column (1-based). Auto-placed when omitted.
row (int | None) – Grid row (1-based). Auto-placed when omitted.
colspan (int) – Number of grid columns to span (default
1).rowspan (int) – Number of grid rows to span (default
1).caption (str) – Caption text displayed below the table.
overflow (bool) – Show a scrollbar when the table overflows the cell.
copy_button (bool) – Show a copy-to-clipboard button on the cell card.
expand_button (bool) – Show a fullscreen-expand button on the cell card.
_params (Any)
- Returns:
The newly created and registered table cell.
- Return type:
- add_tabulator(data=None, *, sheets=None, columns=None, options=None, layout='fitColumns', responsive=False, pagination=None, selectable=False, group_by=None, header_filter=False, frozen_columns=None, frozen_rows=None, movable_columns=True, header_sort=None, row_numbers=False, spreadsheet_mode=False, persistence=False, download=None, height=None, index=False, separator='auto', col=None, row=None, colspan=1, rowspan=1, caption='', overflow=False, copy_button=<UNSET>, expand_button=<UNSET>, tabulator_config=None, _params=None)[source]¶
Add an interactive Tabulator.js table to the slide.
Requires
Plugins.Tabulator()in the deck’s plugin list. The table supports sorting, filtering, pagination, grouping, row/column selection, spreadsheet-style editing, clipboard copy/paste, and CSV/JSON export — all self-contained inside the HTML file with no external requests when using the default bundled source.Pass
datafor a single interactive table, orsheetsfor a multi-tab view (like an Excel workbook). Both accept the same input types asadd_table: adictof columns, alist[list](first row = headers), a pandasDataFrame, a CSV/TSV string, or a path to a CSV/TSV file.- Parameters:
data (dict[str, Any] | list[list[Any]] | pd.DataFrame | str | None) – Tabular data for a single-sheet table. Accepts
dict[str, list](keys = column headers),list[list](first row = headers), a pandasDataFrame, a CSV/TSV string, or a CSV/TSV file path. Defaults toNone; mutually exclusive withsheets.sheets (dict[str, Any] | None) – Multi-sheet mode. A
dictwhose keys become tab titles and whose values are each parsed as tabular data (same types asdata). Column headers appear as the first row of each sheet’s grid. Mutually exclusive withdata. Sorting, filtering, pagination, and grouping options are ignored in multi-sheet mode.columns (list[dict] | None) – Per-column Tabulator column definitions merged over the auto-generated columns. Each dict is matched by
"title"(or"field") — only changed keys need to be specified. Useful keys:"formatter"("money","star","progress","tickCross"),"editor","bottomCalc"/"topCalc","frozen","headerFilter","widthGrow".options (dict | None) – Verbatim dict merged into the Tabulator constructor, overriding all named keyword options. Use for anything not exposed by name —
"movableRows","history","locale", nested tables, etc.layout (str) – Column sizing strategy. One of
"fitColumns"(default),"fitData","fitDataFill","fitDataStretch", or"fitDataTable".responsive (bool) – Collapse overflowing columns into an expandable row instead of horizontal scroll. Defaults to
False.pagination (int | None) – Page size (rows per page).
Nonerenders all rows.selectable (bool | int) –
Trueor a max-count integer to allow row selection.group_by (str | list[str] | None) – Column title (or list of titles) to group rows under collapsible section headers.
header_filter (bool) – Add a text filter input to every column header.
frozen_columns (list[str] | None) – Column titles to pin to the left edge.
frozen_rows (int | None) – Number of rows to pin to the top.
movable_columns (bool) – Allow readers to drag column headers to reorder them. Defaults to
True.header_sort (bool | None) –
True/Falseto force column-header sorting on or off.Nonekeeps Tabulator’s default (sortable). Defaults toFalseinspreadsheet_mode.row_numbers (bool) – Add a frozen left column with sequential row numbers. Numbers are continuous across paginated pages.
spreadsheet_mode (bool) – Enable range cell selection and clipboard copy/paste (Ctrl-C / Ctrl-V). In
sheetsmode also makes cells editable.persistence (bool) – Save the reader’s sort / filter / column-order tweaks in
localStorageand restore on reload. Off by default; the persistence key includes a column-structure hash so stale state is discarded automatically when the table changes.download (list[str] | None) – Export buttons to show on the cell. Accepts
["csv"],["json"], or both. xlsx is not supported (needs SheetJS). In multi-sheet mode downloads the active sheet only.height (str | int | None) – Fixed height for the table, e.g.
"400px"or400(px). Enables Tabulator’s virtual rendering for large tables.index (bool) – Include the pandas DataFrame index as the first column.
separator (Literal['auto', ',', '\t']) –
"auto"(detect from first line),","or"\t"— for string or file inputs only.col (int | None) – Grid column (1-based). Auto-placed when omitted.
row (int | None) – Grid row (1-based). Auto-placed when omitted.
colspan (int) – Number of grid columns to span (default
1).rowspan (int) – Number of grid rows to span (default
1).caption (str) – Caption text displayed below the table.
overflow (bool) – Show a scrollbar on the cell instead of clipping. Defaults to
False(Tabulator scrolls internally).copy_button (bool) – Show a copy-to-clipboard button on the cell card.
expand_button (bool) – Show a fullscreen-expand button on the cell card.
tabulator_config (dict | None) – Final-pass dict merged after all other options, overriding even
options._params (Any)
- Returns:
The newly created and registered table cell.
- Return type:
TabulatorCell
- Raises:
PluginNotDeclaredError – If
Plugins.Tabulator()is not in the deck’s plugin list.ValueError – If both
dataandsheetsare supplied, or if neither is supplied.
- add_list(items, *, ordered=False, col=None, row=None, colspan=1, rowspan=1, caption='', overflow=<UNSET>, copy_button=<UNSET>, expand_button=<UNSET>, _params=None)[source]¶
Add a bulleted or numbered list to the slide.
- Parameters:
items (list[Any]) – The list items to display. Each element is converted to a string and rendered as a list entry.
ordered (bool) – If
True, render as a numbered (<ol>) list. Defaults toFalse(bulleted<ul>).col (int | None) – Grid column (1-based). Auto-placed when omitted.
row (int | None) – Grid row (1-based). Auto-placed when omitted.
colspan (int) – Number of grid columns to span (default
1).rowspan (int) – Number of grid rows to span (default
1).caption (str) – Caption text displayed below the list.
overflow (bool) – Show a scrollbar on the cell instead of clipping.
copy_button (bool) – Show a copy-to-clipboard button on the cell card.
expand_button (bool) – Show a fullscreen-expand button on the cell card.
_params (Any)
- Returns:
The newly created and registered list cell.
- Return type:
- add_plotly(fig, *, save_source=False, col=None, row=None, colspan=1, rowspan=1, caption='', overflow=<UNSET>, copy_button=<UNSET>, expand_button=<UNSET>, _params=None)[source]¶
Add an interactive Plotly chart to the slide.
Requires
Plugins.Plotly()in the deck’s plugin list. The full Plotly figure JSON is embedded in the HTML; the chart is interactive (zoom, pan, hover tooltips) without any server round-trips.- Parameters:
fig (go.Figure) – A
plotly.graph_objects.Figureinstance.save_source (bool) – If
True, embed the raw figure JSON alongside the rendered chart so it can be recovered from the HTML.col (int | None) – Grid column (1-based). Auto-placed when omitted.
row (int | None) – Grid row (1-based). Auto-placed when omitted.
colspan (int) – Number of grid columns to span (default
1).rowspan (int) – Number of grid rows to span (default
1).caption (str) – Caption text displayed below the chart.
overflow (bool) – Show a scrollbar on the cell instead of clipping.
copy_button (bool) – Show a copy-to-clipboard button on the cell card.
expand_button (bool) – Show a fullscreen-expand button on the cell card.
_params (Any)
- Returns:
The newly created and registered Plotly chart cell.
- Return type:
- Raises:
PluginNotDeclaredError – If
Plugins.Plotly()is not in the deck’s plugin list.
- add_matplotlib(fig, *, dpi=150, fmt='svg', to_webp=False, webp_quality=None, save_source=False, lightbox=True, col=None, row=None, colspan=1, rowspan=1, caption='', overflow=<UNSET>, copy_button=<UNSET>, expand_button=<UNSET>, transparent=<UNSET>, halign=<UNSET>, valign=<UNSET>, fontscale=<UNSET>, _params=None)[source]¶
Add a matplotlib figure to the slide.
The figure is rendered to SVG (vector, lossless) or WebP (raster) and embedded as a base64 data URI — no external files needed. For interactive charts see
add_plotly.- Parameters:
fig (matplotlib.figure.Figure) – A
matplotlib.figure.Figureinstance.dpi (int) – Render resolution in dots per inch. Only meaningful when
fmt="webp"(SVG is resolution-independent). Defaults to150.fmt (str) – Output format —
"svg"(default, vector) or"webp"(raster). Overridden to"webp"whento_webp=True.to_webp (bool) – If
True, forces WebP output regardless offmt.webp_quality (int | None) – WebP quality level (1–100).
Noneuses the encoder’s default.save_source (bool) – If
True, the figure is pickled and embedded alongside the rendered image so it can be recovered later.lightbox (bool) – If
True(default), clicking the figure opens it in a fullscreen lightbox viewer.col (int | None) – Grid column (1-based). Auto-placed when omitted.
row (int | None) – Grid row (1-based). Auto-placed when omitted.
colspan (int) – Number of grid columns to span (default
1).rowspan (int) – Number of grid rows to span (default
1).caption (str) – Caption text displayed below the figure.
overflow (bool) – Show a scrollbar on the cell instead of clipping.
copy_button (bool) – Show a copy-to-clipboard button on the cell card.
expand_button (bool) – Show a fullscreen-expand button on the cell card.
transparent (bool) – If
True, the cell background is transparent.halign (str) – Horizontal alignment —
"left","center", or"right".valign (str) – Vertical alignment —
"top","middle", or"bottom".fontscale (float) – Multiplier for this cell’s text size (default
1.0). Composes on top of the deck-widefontsize_scale._params (Any)
- Returns:
The newly created and registered figure cell.
- Return type:
MatplotlibCell
- add_code(code, *, language='python', col=None, row=None, colspan=1, rowspan=1, caption='', overflow=<UNSET>, copy_button=<UNSET>, expand_button=<UNSET>, _params=None)[source]¶
Add a syntax-highlighted code block to the slide.
Requires
Plugins.Highlight()in the deck’s plugin list. Highlighting is applied by Highlight.js at render time in the browser.- Parameters:
code (str) – The source code string to display.
language (str) – Language identifier for syntax highlighting, e.g.
"python","javascript","sql","bash". Passed directly to Highlight.js. Defaults to"python".col (int | None) – Grid column (1-based). Auto-placed when omitted.
row (int | None) – Grid row (1-based). Auto-placed when omitted.
colspan (int) – Number of grid columns to span (default
1).rowspan (int) – Number of grid rows to span (default
1).caption (str) – Caption text displayed below the code block.
overflow (bool) – Show a scrollbar instead of wrapping long lines.
copy_button (bool) – Show a copy-to-clipboard button on the cell card.
expand_button (bool) – Show a fullscreen-expand button on the cell card.
_params (Any)
- Returns:
The newly created and registered code cell.
- Return type:
- Raises:
PluginNotDeclaredError – If
Plugins.Highlight()is not in the deck’s plugin list.
- add_metric(value, label, *, delta=None, delta_label='', lower_is_better=False, symbol_good='▲', symbol_bad='▼', symbol_neutral='—', color_good='#4ade80', color_bad='#f87171', color_neutral='', col=None, row=None, colspan=1, rowspan=1, caption='', overflow=<UNSET>, copy_button=<UNSET>, expand_button=<UNSET>, _params=None)[source]¶
Add a KPI metric card to the slide.
Displays a prominent value with a label and an optional delta indicator (change vs a reference value), colour-coded green / red / neutral.
- Parameters:
value (int | float | str) – The primary metric value. Accepts
int,float, or a pre-formattedstr(e.g."€ 1,234").label (str) – Short descriptor shown below the value (e.g.
"Revenue").delta (int | float | str | None) – Change from a reference value shown as a secondary line with a directional symbol.
Nonehides the delta row entirely.delta_label (str) – Optional text appended after the delta value (e.g.
"vs last year").lower_is_better (bool) – If
True, a negative delta is coloured green and a positive delta red — useful for metrics like error rate or cost. Defaults toFalse.symbol_good (str) – Symbol prepended to a favourable delta. Defaults to
"▲".symbol_bad (str) – Symbol prepended to an unfavourable delta. Defaults to
"▼".symbol_neutral (str) – Symbol shown when delta is exactly zero. Defaults to
"—".color_good (str) – CSS colour for a favourable delta. Defaults to
"#4ade80"(green).color_bad (str) – CSS colour for an unfavourable delta. Defaults to
"#f87171"(red).color_neutral (str) – CSS colour for a neutral delta. Defaults to
""(inherits the theme text colour).col (int | None) – Grid column (1-based). Auto-placed when omitted.
row (int | None) – Grid row (1-based). Auto-placed when omitted.
colspan (int) – Number of grid columns to span (default
1).rowspan (int) – Number of grid rows to span (default
1).caption (str) – Caption text displayed below the metric card.
overflow (bool) – Show a scrollbar on the cell instead of clipping.
copy_button (bool) – Show a copy-to-clipboard button on the cell card.
expand_button (bool) – Show a fullscreen-expand button on the cell card.
_params (Any)
- Returns:
The newly created and registered metric cell.
- Return type:
- add_mermaid(diagram, *, col=None, row=None, colspan=1, rowspan=1, caption='', overflow=<UNSET>, copy_button=<UNSET>, expand_button=<UNSET>, _params=None)[source]¶
Add a Mermaid diagram to the slide.
Requires
Plugins.Mermaid()in the deck’s plugin list. The diagram string is rendered to SVG client-side by Mermaid.js on first display. Supported types include flowcharts, sequence diagrams, Gantt charts, class diagrams, ER diagrams, pie charts, and more.- Parameters:
diagram (str) –
A Mermaid diagram definition string, e.g.:
""" flowchart LR A --> B --> C """
col (int | None) – Grid column (1-based). Auto-placed when omitted.
row (int | None) – Grid row (1-based). Auto-placed when omitted.
colspan (int) – Number of grid columns to span (default
1).rowspan (int) – Number of grid rows to span (default
1).caption (str) – Caption text displayed below the diagram.
overflow (bool) – Show a scrollbar on the cell instead of clipping.
copy_button (bool) – Show a copy-to-clipboard button on the cell card.
expand_button (bool) – Show a fullscreen-expand button on the cell card.
_params (Any)
- Returns:
The newly created and registered diagram cell.
- Return type:
- Raises:
PluginNotDeclaredError – If
Plugins.Mermaid()is not in the deck’s plugin list.
- add_html(content, *, col=None, row=None, colspan=1, rowspan=1, caption='', overflow=<UNSET>, copy_button=<UNSET>, expand_button=<UNSET>, _params=None)[source]¶
Add a raw HTML cell to the slide.
The content is injected verbatim into the slide DOM without escaping or sanitisation. Use for custom widgets, embedded SVGs, or any markup that Montin’s other cells do not cover.
- Parameters:
content (str) – Raw HTML string to inject into the cell body.
col (int | None) – Grid column (1-based). Auto-placed when omitted.
row (int | None) – Grid row (1-based). Auto-placed when omitted.
colspan (int) – Number of grid columns to span (default
1).rowspan (int) – Number of grid rows to span (default
1).caption (str) – Caption text displayed below the HTML block.
overflow (bool) – Show a scrollbar on the cell instead of clipping.
copy_button (bool) – Show a copy-to-clipboard button on the cell card.
expand_button (bool) – Show a fullscreen-expand button on the cell card.
_params (Any)
- Returns:
The newly created and registered HTML cell.
- Return type:
- add_iframe(url, *, col=None, row=None, colspan=1, rowspan=1, caption='', overflow=<UNSET>, copy_button=<UNSET>, expand_button=<UNSET>, _params=None)[source]¶
Embed an external URL in an iframe cell.
The URL is loaded in a sandboxed
<iframe>at render time. The report must be opened in a browser with network access for the embedded page to load.- Parameters:
url (str) – The URL to embed (e.g.
"https://example.com").col (int | None) – Grid column (1-based). Auto-placed when omitted.
row (int | None) – Grid row (1-based). Auto-placed when omitted.
colspan (int) – Number of grid columns to span (default
1).rowspan (int) – Number of grid rows to span (default
1).caption (str) – Caption text displayed below the iframe.
overflow (bool) – Show a scrollbar on the cell instead of clipping.
copy_button (bool) – Show a copy-to-clipboard button on the cell card.
expand_button (bool) – Show a fullscreen-expand button on the cell card.
_params (Any)
- Returns:
The newly created and registered iframe cell.
- Return type:
- add_empty(*, col=None, row=None, colspan=1, rowspan=1, transparent=<UNSET>, halign=<UNSET>, valign=<UNSET>, fontscale=<UNSET>, _params=None)[source]¶
Add an empty placeholder cell to reserve space on the grid.
Useful for leaving intentional gaps in complex layouts — for example, to place content in columns 1 and 3 while keeping column 2 blank.
- Parameters:
col (int | None) – Grid column (1-based). Auto-placed when omitted.
row (int | None) – Grid row (1-based). Auto-placed when omitted.
colspan (int) – Number of grid columns to span (default
1).rowspan (int) – Number of grid rows to span (default
1).transparent (bool) – If
True, the placeholder has no background and no border — invisible to the reader.halign (str) – Horizontal alignment —
"left","center", or"right".valign (str) – Vertical alignment —
"top","middle", or"bottom".fontscale (float) – Multiplier for this cell’s text size (default
1.0). Composes on top of the deck-widefontsize_scale._params (Any)
- Returns:
The newly created and registered empty cell.
- Return type:
- add_image_slider(sources, *, captions=None, to_webp=False, webp_quality=None, save_source=False, col=None, row=None, colspan=1, rowspan=1, caption='', overflow=<UNSET>, copy_button=<UNSET>, expand_button=<UNSET>, _params=None)[source]¶
Add an image carousel to the slide.
Displays a sequence of images (or matplotlib figures) as a navigable slideshow with previous/next controls. Each image can have its own overlay caption.
- Parameters:
sources (list) –
Ordered list of image sources. Each element may be:
A file path (
strorpathlib.Path).A URL (
"https://...").A base64 data URI.
A
matplotlib.figure.Figure— rendered inline.
captions (list | None) – Per-image caption strings displayed as overlays. Must match the length of
sourceswhen provided. Defaults to empty strings for all images.to_webp (bool) – Convert raster images to WebP before embedding. Reduces file size for photographs.
webp_quality (int | None) – WebP quality level (1–100).
Noneuses the encoder’s default.save_source (bool) – If
True, original source files are embedded alongside the processed images.col (int | None) – Grid column (1-based). Auto-placed when omitted.
row (int | None) – Grid row (1-based). Auto-placed when omitted.
colspan (int) – Number of grid columns to span (default
1).rowspan (int) – Number of grid rows to span (default
1).caption (str) – Master caption displayed below the entire slider cell.
overflow (bool) – Show a scrollbar on the cell instead of clipping.
copy_button (bool) – Show a copy-to-clipboard button on the cell card.
expand_button (bool) – Show a fullscreen-expand button on the cell card.
_params (Any)
- Returns:
The newly created and registered slider cell.
- Return type:
- property cells: list[Cell]¶
Ordered list of all cells registered on this slide.
- property cell_map: dict[Hashable, Cell]¶
Mapping from cell id to cell object for all cells on this slide.
Cells¶
- class montin.cells.text.TextCell(content, params, markdown=True)[source]¶
Bases:
CellText with Markdown and LaTeX support (via MathJax).
- Parameters:
content (str)
params (CellParams)
markdown (bool)
- class montin.cells.misc.MetricCell(value, label, delta, delta_label, lower_is_better, symbol_good, symbol_bad, symbol_neutral, color_good, color_bad, color_neutral, params)[source]¶
Bases:
CellKPI card: large value + label + optional delta.
By default a positive delta is coloured green and negative red. Set
lower_is_better=Trueto invert that (e.g. defect counts, latency).symbol_good,symbol_bad,symbol_neutralcustomise the indicator character — pass any string, including emoji (e.g."✅","🔴").- Parameters:
value (int | float | str)
label (str)
delta (int | float | str | None)
delta_label (str)
lower_is_better (bool)
symbol_good (str)
symbol_bad (str)
symbol_neutral (str)
color_good (str)
color_bad (str)
color_neutral (str)
params (CellParams)
- class montin.cells.table.TableCell(data, separator, index, params)[source]¶
Bases:
Cell- Static HTML data table. Accepts:
dict[str, list] → keys = headers, values = columns
list[list] → first sub-list = headers
pd.DataFrame
str CSV or TSV → separator auto-detected
path to a CSV/TSV file → read, then parsed as above
- Parameters:
data (dict[str, Any] | list[list[Any]] | pd.DataFrame | str)
separator (Literal['auto', ',', '\t'])
index (bool)
params (CellParams)
- class montin.cells.image.ImageCell(source, lightbox, params, to_webp=False, webp_quality=None, save_source=False)[source]¶
Bases:
CellImage with lightbox (zoom/pan) and thumbnails for all images on the slide. Accepts a local path, URL, or base64 string. Effective overflow default: False (image fits the cell).
- Parameters:
source (str | Path)
lightbox (bool)
params (CellParams)
to_webp (bool)
webp_quality (int | None)
save_source (bool)
- class montin.cells.image_slider.ImageSliderCell(sources, captions, params, to_webp=False, webp_quality=None, save_source=False)[source]¶
Bases:
CellImage carousel with prev/next buttons. Clicking an image opens the lightbox with zoom/pan. Slider images also appear as lightbox thumbnails.
- Parameters:
sources (list)
captions (list[str])
params (CellParams)
to_webp (bool)
webp_quality (int | None)
save_source (bool)
- class montin.cells.misc.ListCell(items, ordered, params)[source]¶
Bases:
CellBullet or numbered list, with nested sub-levels.
- Parameters:
items (list[Any])
ordered (bool)
params (CellParams)
- class montin.cells.misc.CodeCell(code, language, params)[source]¶
Bases:
CellCode block with syntax highlighting. Effective copy_button default: True. Requires Plugins.Highlight().
- Parameters:
code (str)
language (str)
params (CellParams)
- class montin.cells.plotly.PlotlyCell(fig, params, save_source=False)[source]¶
Bases:
CellInteractive Plotly figure embedded as JSON. Effective overflow default: False. Requires Plugins.Plotly().
- Parameters:
fig (go.Figure)
params (CellParams)
save_source (bool)
- class montin.cells.misc.MermaidCell(diagram, params)[source]¶
Bases:
CellMermaid diagram (flowchart, sequenceDiagram, architecture, etc.). Effective overflow default: False. Requires Plugins.Mermaid().
- Parameters:
diagram (str)
params (CellParams)
- class montin.cells.misc.HtmlCell(content, params)[source]¶
Bases:
CellRaw HTML injected without escaping.
- Parameters:
content (str)
params (CellParams)
Exceptions¶
- class montin.CellPlacementError[source]¶
Bases:
MontinErrorRaised when a cell cannot be placed on the canvas.
Cases: - col or row out of range (< 1 or > nrows/ncols) - col + colspan - 1 > ncols or row + rowspan - 1 > nrows - position already occupied by another cell
- class montin.PluginNotDeclaredError[source]¶
Bases:
MontinErrorRaised when a cell requires a plugin not declared in Deck.
Example: add_code() without Plugins.Highlight() in the plugins list.
- class montin.ThemeNotFoundError[source]¶
Bases:
MontinErrorRaised when the folder for the specified theme is not found.
- class montin.InvalidDataError[source]¶
Bases:
MontinErrorRaised when the type or format of data passed to an add_* method is invalid or cannot be interpreted.
Example: add_table() receives an unsupported type, or a malformed CSV string.
- class montin.SecurityError[source]¶
Bases:
MontinErrorRaised when a Security(…) constraint cannot be satisfied.
Cases: - block_external=True but a plugin was explicitly set to source=”cdn” - block_external=True but the rendered report still contains an external
(http/https) resource URL