Row and Column¶
- class respysive.Row(content, gap=None, align_items=None, justify_content=None, **kwargs)[source]¶
Bases:
objectContainer for horizontal row layout in Bootstrap grid system.
A Row creates a horizontal container (<div class=”row”>) that holds Column objects or other content. Rows can be nested inside Columns to create complex multi-level layouts.
- Parameters:
content – Single content item or list of items. Items can be Column objects, Row objects (for nesting), or any content type supported by respysive (charts, images, text, etc.). Non-Column items are auto-wrapped in col-md-12 containers.
gap (int or str, optional) – Bootstrap gap utility for spacing between columns. Can be integer 0-5 for Bootstrap gap classes (g-0 to g-5), or a string for custom gap classes. Defaults to None (no gap).
align_items (str, optional) – Vertical alignment of columns within the row. One of: ‘start’, ‘center’, ‘end’, ‘baseline’, ‘stretch’. Maps to Bootstrap align-items-* classes. Defaults to None.
justify_content (str, optional) – Horizontal alignment/distribution of columns. One of: ‘start’, ‘center’, ‘end’, ‘between’, ‘around’, ‘evenly’. Maps to Bootstrap justify-content-* classes. Defaults to None.
**kwargs – Additional CSS styles and classes to apply to the row. Use underscore notation for CSS properties (e.g., background_color=’#fff’). Use ‘class’ key for Bootstrap classes (string or list).
- Variables:
content (list) – Normalized list of content items
gap (int or str or None) – Gap configuration
align_items (str or None) – Vertical alignment setting
justify_content (str or None) – Horizontal alignment setting
kwargs (dict) – Additional styling options
- Raises:
ParameterValidationError – If parameters fail validation (empty content, invalid gap value, invalid alignment options, etc.)
Examples
Simple two-column row:
row = Row([ Column(6, chart1), Column(6, chart2) ])
Row with gap and alignment:
row = Row([ Column(4, image), Column(8, text) ], gap=3, align_items='center')
Row with custom styling:
row = Row([content1, content2], background_color='#f8f9fa', padding='20px', **{'class': 'border'})
Nested row structure:
row = Row([ Column(8, main_content), Column(4, [ Row(sidebar_item1), Row(sidebar_item2) ]) ])
- class respysive.Column(width, content, offset=None, order=None, **kwargs)[source]¶
Bases:
objectContainer for column layout in Bootstrap grid system.
A Column creates a vertical container (
<div class="col-md-N">) within a Row. Columns define the width and positioning of content within the Bootstrap 12-column grid system. They can contain any content type, including nested Rows.- Parameters:
width (int or str or dict) – Column width: an integer from 1 to 12 (
col-md-{width}),'auto'for a column sized by its content, or a dictionary of widths per breakpoint such as{'md': 8, 'sm': 12}(breakpoints'xs','sm','md','lg','xl','xxl').content – Content to display in the column. Can be a single item or list of items. Items can be Row objects (for nesting), Column objects, or any content type supported by respysive (charts, images, text, etc.).
offset (int, optional) – Number of columns to offset (shift right) this column. Must be 0-11. Creates space before the column. Defaults to None.
order (int or str, optional) – Visual order of the column: an integer from 1 to 12,
'first'or'last'. Defaults to None (source order).**kwargs – Additional CSS styles and classes to apply to the column. Use underscore notation for CSS properties (e.g., padding=’20px’). Use ‘class’ key for Bootstrap classes (string or list).
content_widthandcontent_heightset the size of the chart or map inside the column (e.g., 800, ‘90%’, ‘500px’).
- Variables:
width (int or str or dict) – Width configuration
content (list) – Normalized list of content items
offset (int or None) – Offset setting
order (int or str or None) – Order setting
kwargs (dict) – Additional styling options
- Raises:
ParameterValidationError – If parameters fail validation (invalid width, empty content, invalid offset/order values, etc.)
Examples
Fixed width column:
col = Column(8, my_chart)
Auto-sized column:
col = Column('auto', small_widget)
Responsive column (8 cols on desktop, full width on mobile):
col = Column({'md': 8, 'sm': 12}, content)
Column with offset and styling:
col = Column(6, content, offset=3, # Center in 12-col grid padding='15px', **{'class': 'border'})
Column with content dimensions:
col = Column(8, map_config, content_width=800, content_height=600)
Column with nested rows:
col = Column(4, [ Row(header_text), Row(image), Row(footer_text) ])
Column with custom order (display second visually, first in markup):
col = Column(6, content, order=2)