Slide

class respysive.Slide(center=False, overflow=None, **kwargs)[source]

Bases: object

Individual slide container with content management.

Handles content addition, layout, and rendering for presentation slides.

Parameters:
  • center (bool) – Enable vertical centering for slide content. Default: False

  • overflow (str) – How content taller than the slide is handled, overriding the presentation default: ‘fit’ (shrink text, then scale content), ‘warn’ or ‘visible’. Default: None (use the presentation setting)

  • **kwargs – Additional HTML attributes and CSS classes. Common kwargs include: ‘class’ (str or list) for CSS classes, ‘data-background-image’ (str) for background image URL, ‘data-background-size’ (str) for background size, ‘data-background-position’ (str) for background position, ‘data-background-color’ (str) and ‘data-background-gradient’ (str).

Example

Create slide with custom class for overlay:

slide = Slide(**{'class': 'branded'})

Multiple classes and background:

slide = Slide(**{
    'class': ['branded', 'dark-theme'],
    'data-background-image': 'bg.jpg'
})
add_custom_content(library, config, cdn=None, init_script=None, div_style=None, columns=None, styles=None, **kwargs)[source]

Add custom content using external JavaScript libraries via CDN.

Parameters:
  • library (str) – Name of the library (e.g., “maplibre-gl”)

  • config (dict) – Configuration object for the library

  • cdn (dict) – Dictionary with ‘css’ and ‘js’ lists of CDN URLs

  • init_script (str) – Custom initialization script

  • div_style (dict) – CSS styles for the container div

  • columns (list) – Column widths (defaults to [12])

  • styles (list) – Bootstrap styles for the content

  • **kwargs – Additional styling options

Example

>>> slide.add_custom_content(
...     library="maplibre-gl",
...     config={
...         "style": "https://demotiles.maplibre.org/style.json",
...         "center": [2.3522, 48.8566],
...         "zoom": 10
...     },
...     cdn={
...         "css": ["https://unpkg.com/maplibre-gl@2.4.0/dist/maplibre-gl.css"],
...         "js": ["https://unpkg.com/maplibre-gl@2.4.0/dist/maplibre-gl.js"]
...     },
...     div_style={"height": "500px"}
... )
add_maplibre_map(center, zoom=10, style=None, markers=None, legend=None, openstreetmap=False, scale=True, navigation=True, columns=None, styles=None)[source]

Add a MapLibre GL JS map easily.

Parameters:
  • center (list) – Center coordinates [longitude, latitude]

  • zoom (int) – Zoom level (default 10)

  • style (str) – Map style URL (default: MapLibre demo, ignored if openstreetmap=True)

  • markers (list) – List of markers with coordinates, popup, icon (Font Awesome), color

  • legend (dict) – Dictionary with title and items for legend

  • openstreetmap (bool) – Use OpenStreetMap as background (default False)

  • scale (bool) – Show scale control (default True)

  • navigation (bool) – Show navigation controls (default True)

  • columns (list) – Column widths (default [12])

  • styles (list) – Bootstrap styles

Example

>>> slide.add_maplibre_map(
...     center=[2.3522, 48.8566],
...     zoom=12,
...     openstreetmap=True,
...     markers=[
...         {
...             "coordinates": [2.3522, 48.8566],
...             "icon": "fas fa-tower-broadcast",
...             "color": "#e74c3c",
...             "popup": "Eiffel Tower"
...         }
...     ],
...     legend={
...         "title": "Points of Interest",
...         "items": [
...             {"icon": "fas fa-tower-broadcast", "color": "#e74c3c", "label": "Monuments"}
...         ]
...     }
... )
add_maplibre_lines_map(center, zoom=10, lines=None, markers=None, legend=None, openstreetmap=False, scale=True, navigation=True, columns=None, styles=None)[source]

Add a MapLibre map with variable width lines.

Parameters:
  • center (list) – Center coordinates [longitude, latitude]

  • zoom (int) – Zoom level (default 10)

  • lines (list) – List of lines with coordinates, width, color, popup

  • markers (list) – List of markers (optional)

  • legend (dict) – Dictionary with title and items for legend

  • openstreetmap (bool) – Use OpenStreetMap as background (default False)

  • scale (bool) – Show scale control (default True)

  • navigation (bool) – Show navigation controls (default True)

  • columns (list) – Column widths (default [12])

  • styles (list) – Bootstrap styles

Example

>>> slide.add_maplibre_lines_map(
...     center=[2.3522, 48.8566],
...     zoom=12,
...     openstreetmap=True,
...     lines=[
...         {
...             "coordinates": [[2.3522, 48.8566], [2.3376, 48.8606]],
...             "width": 8,
...             "color": "#e74c3c",
...             "popup": "Main line - Traffic: 10000 vehicles/day"
...         },
...         {
...             "coordinates": [[2.3376, 48.8606], [2.3488, 48.8534]],
...             "width": 4,
...             "color": "#3498db",
...             "popup": "Secondary line - Traffic: 5000 vehicles/day"
...         }
...     ],
...     legend={
...         "title": "Road Traffic",
...         "items": [
...             {"type": "line", "width": 8, "color": "#e74c3c", "label": "High traffic (>8000)"},
...             {"type": "line", "width": 4, "color": "#3498db", "label": "Medium traffic (4000-8000)"}
...         ]
...     }
... )
add_maplibre_circles_map(center, zoom=10, circles=None, markers=None, legend=None, openstreetmap=False, scale=True, navigation=True, min_radius=5, max_radius=50, columns=None, styles=None)[source]

Add a MapLibre map with proportional circles (radius = √value).

Parameters:
  • center (list) – Center coordinates [longitude, latitude]

  • zoom (int) – Zoom level (default 10)

  • circles (list) – List of circles with coordinates, value, color, popup

  • markers (list) – List of markers (optional)

  • legend (dict) – Dictionary with title (automatic legend with min/median/max)

  • openstreetmap (bool) – Use OpenStreetMap as background (default False)

  • scale (bool) – Show scale control (default True)

  • navigation (bool) – Show navigation controls (default True)

  • min_radius (int) – Minimum radius in pixels (default 5)

  • max_radius (int) – Maximum radius in pixels (default 50)

  • columns (list) – Column widths (default [12])

  • styles (list) – Bootstrap styles

Example

>>> slide.add_maplibre_circles_map(
...     center=[2.3522, 48.8566],
...     zoom=10,
...     openstreetmap=True,
...     circles=[
...         {
...             "coordinates": [2.3522, 48.8566],
...             "value": 2200000,
...             "color": "#e74c3c",
...             "popup": "Paris: 2.2M people"
...         },
...         {
...             "coordinates": [2.3376, 48.8606],
...             "value": 700000,
...             "color": "#3498db",
...             "popup": "Lyon: 700k people"
...         }
...     ],
...     legend={"title": "City Population"},
...     min_radius=10,
...     max_radius=60
... )
add_maplibre_choropleth_map(center, zoom=10, geojson=None, color_property=None, color_rules=None, legend=None, openstreetmap=False, scale=True, navigation=True, popup=None, columns=None, styles=None)[source]

Add a MapLibre choropleth map (color-filled areas).

Parameters:
  • center (list) – Center coordinates [longitude, latitude]

  • zoom (int) – Zoom level (default 10)

  • geojson (dict) – GeoJSON data with properties

  • color_property (str) – Property name for coloring

  • color_rules (list) – Color rules [{“operator”: “>=”, “value”: 100, “color”: “#ff0000”}]

  • legend (dict) – Manual legend {“choropleth”: {“type”: “discrete”, “items”: […]}}

  • openstreetmap (bool) – Use OpenStreetMap as background (default False)

  • scale (bool) – Show scale control (default True)

  • navigation (bool) – Show navigation controls (default True)

  • popup (str) – Popup template with variables {propertyName}

  • columns (list) – Column widths (default [12])

  • styles (list) – Bootstrap styles

Example

>>> slide.add_maplibre_choropleth_map(
...     center=[2.3522, 48.8566],
...     zoom=6,
...     geojson=regions_data,
...     color_property="population",
...     color_rules=[
...         {"operator": ">=", "value": 1000000, "color": "#d73027"},
...         {"operator": ">=", "value": 500000, "color": "#f46d43"},
...         {"operator": ">=", "value": 100000, "color": "#fdae61"},
...         {"operator": "<", "value": 100000, "color": "#fee08b"}
...     ],
...     legend={
...         "title": "Population by Region",
...         "choropleth": {
...             "type": "discrete",
...             "items": [
...                 {"color": "#d73027", "label": "> 1M inhabitants"},
...                 {"color": "#f46d43", "label": "500k - 1M inhabitants"},
...                 {"color": "#fdae61", "label": "100k - 500k inhabitants"},
...                 {"color": "#fee08b", "label": "< 100k inhabitants"}
...             ]
...         }
...     },
...     popup="<b>{name}</b><br>Population: {population} people"
... )
add_maplibre_choropleth_with_data_join(center, zoom=10, geojson_id=None, join_data=None, join_key=None, color_property=None, color_rules=None, legend=None, openstreetmap=False, scale=True, navigation=True, popup=None, columns=None, styles=None)[source]

Add an optimized MapLibre choropleth map with data join.

This method uses the cache system to avoid GeoJSON data duplication.

Parameters:
  • center (list) – Center coordinates [longitude, latitude]

  • zoom (int) – Zoom level (default 10)

  • geojson_id (str) – Reference ID to global GeoJSON data (via add_global_geojson)

  • join_data (dict) – Data to join with geometry (dict or list)

  • join_key (str) – Common key for joining (e.g., ‘id’, ‘code_insee’)

  • color_property (str) – Property to use for coloring after join

  • color_rules (list) – Color rules list [{‘operator’: ‘>=’, ‘value’: 10, ‘color’: ‘#red’}]

  • legend (dict) – Legend configuration

  • openstreetmap (bool) – Use OpenStreetMap instead of default style

  • scale (bool) – Show scale control

  • navigation (bool) – Show navigation controls

  • popup (str) – Popup HTML template with variables {property_name}

  • columns (list) – Bootstrap layout [12]

  • styles (list) – CSS styles and Bootstrap classes

Example

>>> presentation.add_global_geojson('france_regions', geojson_regions)
>>> slide.add_maplibre_choropleth_with_data_join(
...     center=[2.3, 46.8], zoom=6,
...     geojson_id='france_regions',
...     join_data={'75': {'population': 2000000}, '69': {'population': 500000}},
...     join_key='code_insee',
...     color_property='population',
...     color_rules=[
...         {'operator': '>=', 'value': 1000000, 'color': '#d73027'},
...         {'operator': '>=', 'value': 500000, 'color': '#fc8d59'}
...     ]
... )
add_title(text, tag='h3', icon=None, fragment=None, **kwargs)[source]

Add a heading element to the slide.

Parameters:
  • text (str) – The text of the heading

  • tag (str) – The HTML tag to use for the heading (h1-h6). Default is ‘h3’

  • icon (str) – FontAwesome icon class for the heading

  • fragment (bool or str, optional) – Reveal the title as a fragment. True for the default fade-in, or a fragment style such as ‘fade-up’

  • **kwargs – Additional CSS styles and HTML classes. Use underscore for CSS properties (e.g., font_size=’20px’). The ‘class’ key accepts string or list of strings.

Example

>>> slide.add_title("My Title", tag="h2", icon="fas fa-star")
>>> slide.add_title("Styled Title", color="blue", **{"class": ["title", "highlight"]})
add_notes(notes)[source]

Add speaker notes to the slide.

Speaker notes are visible in the speaker view opened by pressing ‘S’ during the presentation. They support plain text, HTML, and Markdown.

Parameters:

notes (str) – Speaker notes content. Can be plain text, HTML, or Markdown.

Example

>>> slide.add_notes("Remember to emphasize this point")
>>> slide.add_notes("**Important:** This is a key concept")
>>> slide.add_notes("<ul><li>Point 1</li><li>Point 2</li></ul>")

Note

Press ‘S’ during presentation to open Speaker View with notes.

add_content(content, columns=None, styles=None, shared_data_ids=None, content_types=None, dimensions=None, fragment=None, fragment_items=None, **kwargs)[source]

Add content items to slide using Bootstrap grid layout.

Parameters:
  • content (list) – List of content items (strings, figures, charts, etc.)

  • columns – Bootstrap column sizes for each item (default: [12])

  • styles (list) – Style dictionaries for each content item

  • shared_data_ids (list) – Shared data IDs for each item (for Plotly charts)

  • content_types (list) – Content types to force for each item (‘plotly’, ‘matplotlib’, ‘maplibre’, ‘altair’, ‘image’, ‘video’, ‘latex’, ‘text’, ‘json’)

  • dimensions (list) – List of dimension dicts for each item (e.g., [{‘width’: 800, ‘height’: 600}, {‘width’: ‘90%’}])

  • fragment – Reveal items one step at a time. True (default fade-in), a fragment style (‘fade-up’, ‘highlight-red’, …) applied to every item, or a list with one value per item (None for items shown immediately)

  • fragment_items – Reveal list items (<li>) inside the content one by one. True or a fragment style, or a list with one value per item

  • **kwargs – Additional styling options applied to all items (overridden by individual dimensions)

add_card(cards, styles=None, fragment=None)[source]

Add Bootstrap cards to the slide.

Parameters:
  • cards (list) –

    List of card dictionaries. Each card can contain:

    • title: Card title text

    • title_style: CSS dictionary for title (e.g., {‘font-size’: ‘20px’, ‘color’: ‘#333’})

    • title_tag: HTML tag for title (h1-h6, default: ‘h5’)

    • text: Card body text (supports Markdown and LaTeX)

    • text_style: CSS dictionary for text (e.g., {‘font-size’: ‘85%’, ‘color’: ‘#666’})

    • image: URL or path to image file

    • image_style: CSS dictionary for image (e.g., {‘max-height’: ‘300px’, ‘object-fit’: ‘contain’})

    • graph: Chart object (Matplotlib figure, Plotly JSON, Altair spec, MapLibre config)

  • styles (list) – List of style dictionaries for card containers (backgrounds, borders, etc.)

  • fragment – Reveal cards one at a time. True, a fragment style such as ‘fade-up’, or a list with one value per card

Example

>>> cards = [
...     {
...         'title': 'Sales Report',
...         'title_style': {'font-size': '24px', 'color': '#e63946'},
...         'title_tag': 'h3',
...         'text': 'Revenue data for Q3',
...         'text_style': {'font-size': '100%'},
...         'graph': plotly_chart
...     },
...     {
...         'title': 'Map View',
...         'graph': {'center': [2.35, 48.85], 'zoom': 10, 'openstreetmap': True}
...     }
... ]
>>> slide.add_card(cards)
add_title_page(title_page_content, styles=None, title_page_class='', background_image=None, background_style=None)[source]

Add a title page to the slide.

Parameters:
  • title_page_content (dict) – dictionary that contains the following keys: ‘title’, ‘subtitle’, ‘authors’, ‘logo’

  • styles (list) – list of dictionaries that contains the css styles for each element of the title page. The keys of the dictionaries are: ‘title’, ‘subtitle’, ‘authors’, ‘logo’

  • title_page_class (str) – additional CSS class for the title-page div

  • background_image (str) – URL or path to background image

  • background_style (dict) – dictionary with background styling options like ‘background-size’, ‘background-position’, etc.

add_split_title_page(title_page_content, custom_content, title_column_width=6, custom_column_width=6, title_page_class='', custom_content_style=None, title_styles=None, title_column_style=None, background_image=None, background_style=None, full_height=False)[source]

Add a split title page with two columns.

Creates a title page divided into two columns using Bootstrap grid system. When full_height is enabled, the page covers the entire slide viewport with no margins using Reveal.js native background system and absolute positioning.

Parameters:
  • title_page_content (dict) – Dictionary with keys ‘title’, ‘subtitle’, ‘authors’, ‘logo’ (all optional)

  • custom_content – Content to display in the second column (string, figure, image, chart, etc.)

  • title_column_width (int) – Width of the title column in Bootstrap units (1-12, default: 6)

  • custom_column_width (int) – Width of the custom content column in Bootstrap units (1-12, default: 6)

  • title_page_class (str) – Additional CSS class for the title-page div

  • custom_content_style (dict) – Style dictionary for the custom content column (e.g., {‘background-color’: ‘#fff’, ‘padding’: ‘40px’})

  • title_styles (list) – List of style dictionaries for title elements (title, subtitle, authors, logo)

  • title_column_style (dict) – Style dictionary for the title column container (e.g., {‘background-color’: ‘#1d3557’, ‘color’: ‘#f1faee’, ‘padding’: ‘40px’})

  • background_image (str) – URL or path to background image

  • background_style (dict) – Dictionary with background styling options (‘background-size’, ‘background-position’, etc.)

  • full_height (bool) – If True, the split page covers the full slide viewport with no margins. Uses Reveal.js background gradient system for optimal rendering. Default: False

Example

Create a full-height split title page:

slide = Slide()
slide.add_split_title_page(
    title_page_content={
        'title': 'My Presentation',
        'subtitle': 'A Great Topic',
        'authors': 'Author Name'
    },
    custom_content=logo_url,
    title_column_width=8,
    custom_column_width=4,
    full_height=True,
    title_column_style={
        'background-color': '#1d3557',
        'color': '#f1faee',
        'padding': '40px'
    },
    custom_content_style={
        'background-color': '#e63946',
        'padding': '30px',
        'text-align': 'center'
    }
)
add_layout(layout, **kwargs)[source]

Add a Row or Column layout to the slide.

This method provides an alternative to add_content() for creating complex nested Bootstrap grid layouts using Row and Column objects. It enables explicit control over layout structure while maintaining full integration with the respysive content handling system.

Parameters:
  • layout (Row or Column) – Layout structure to add to the slide. Can be a Row containing Columns, a standalone Column, or nested Row/Column structures of any depth.

  • **kwargs – Additional styling options applied to the layout. These are passed to the content handler system but are typically overridden by Row/Column kwargs.

Raises:

ValueError – If layout is not a Row or Column instance

Examples

Simple two-column layout:

layout = Row([
    Column(8, my_chart),
    Column(4, "Description text")
])
slide.add_layout(layout)

Nested layout with chart and stacked sidebar:

layout = Row([
    Column(8, my_chart),
    Column(4, [
        Row(header_text),
        Row(sidebar_chart),
        Row(footer_text)
    ])
])
slide.add_layout(layout)

Layout with styling and alignment:

layout = Row([
    Column(6, map_visual, **{'class': 'border'}),
    Column(6, [
        Row(title, gap=2),
        Row([
            Column(6, chart1),
            Column(6, chart2)
        ])
    ])
], gap=3, align_items='center')
slide.add_layout(layout)

Responsive layout:

layout = Row([
    Column({'md': 8, 'sm': 12}, chart),  # 8 cols desktop, full mobile
    Column({'md': 4, 'sm': 12}, text)
])
slide.add_layout(layout)

Note

The existing add_content() method remains fully functional. Use add_layout() when you need explicit control over nested layouts, and use add_content() for simple grid layouts.