Bootstrap themed components for use in Plotly Dash applications
—
Navigation bars, breadcrumbs, tabs, and other navigation elements for creating intuitive user interfaces and application structure.
Primary navigation bar component with branding, links, and responsive behavior.
class Navbar:
"""
Navigation bar component with Bootstrap styling and responsive behavior.
Args:
children: Navigation items (NavItem, NavLink, etc.)
id (str): Component identifier for callbacks
style (dict): Inline CSS styles
class_name (str): Additional CSS classes
brand (str|component): Brand text or component
brand_href (str): URL for brand link
brand_style (dict): Styles for brand element
brand_external_link (bool): Open brand link in new tab
color (str): Navbar color theme - "primary", "secondary", "success", "info", "warning", "danger", "light", "dark"
dark (bool): Use dark theme (overrides color for text contrast)
light (bool): Use light theme
fixed (str): Fixed positioning - "top" or "bottom"
sticky (str): Sticky positioning - "top"
expand (str|bool): Responsive breakpoint for collapsing - "sm", "md", "lg", "xl", True (never collapse), False (always collapse)
"""
def __init__(self, children=None, id=None, style=None, class_name=None,
brand=None, brand_href=None, brand_style=None, brand_external_link=False,
color=None, dark=None, light=None, fixed=None, sticky=None, expand="lg", **kwargs): ...Brand component for navbar with text or logo content.
class NavbarBrand:
"""
Navbar brand component for logo or site name.
Args:
children: Brand content (text, image, or components)
id (str): Component identifier
href (str): Brand link URL
external_link (bool): Open link in new tab
style (dict): Inline CSS styles
class_name (str): Additional CSS classes
"""
def __init__(self, children=None, id=None, href=None, external_link=False,
style=None, class_name=None, **kwargs): ...Mobile menu toggle button for responsive navbar collapse.
class NavbarToggler:
"""
Toggle button for collapsible navbar content on mobile.
Args:
id (str): Component identifier for callbacks (to control Collapse component)
style (dict): Inline CSS styles
class_name (str): Additional CSS classes
"""
def __init__(self, id=None, style=None, class_name=None, **kwargs): ...Navigation component for organizing navigation links and items.
class Nav:
"""
Navigation container for organizing navigation links.
Args:
children: Navigation items (NavItem, NavLink, etc.)
id (str): Component identifier
style (dict): Inline CSS styles
class_name (str): Additional CSS classes
vertical (bool): Stack navigation items vertically
pills (bool): Use pill-style navigation
fill (bool): Fill available width proportionally
justified (bool): Fill available width equally
navbar (bool): Style for use in navbar
"""
def __init__(self, children=None, id=None, style=None, class_name=None,
vertical=False, pills=False, fill=False, justified=False, navbar=False, **kwargs): ...Individual navigation item container.
class NavItem:
"""
Individual navigation item container.
Args:
children: Content (typically NavLink)
id (str): Component identifier
style (dict): Inline CSS styles
class_name (str): Additional CSS classes
"""
def __init__(self, children=None, id=None, style=None, class_name=None, **kwargs): ...Navigation link component with active state and styling.
class NavLink:
"""
Navigation link with active state support.
Args:
children: Link text or content
id (str): Component identifier for callbacks
href (str): Link URL
active (bool): Active state styling
disabled (bool): Disabled state styling
external_link (bool): Open link in new tab
style (dict): Inline CSS styles
class_name (str): Additional CSS classes
"""
def __init__(self, children=None, id=None, href=None, active=False, disabled=False,
external_link=False, style=None, class_name=None, **kwargs): ...Simplified navbar component with common configuration options.
class NavbarSimple:
"""
Simplified navbar with common patterns pre-configured.
Args:
children: Additional navbar content
brand (str|component): Brand text or component
brand_href (str): Brand link URL
links (list): List of link dictionaries with "label" and "href" keys
links_left (list): Links positioned on the left side
fluid (bool): Use fluid container
color (str): Navbar color theme
dark (bool): Use dark theme
light (bool): Use light theme
fixed (str): Fixed positioning
sticky (str): Sticky positioning
expand (str|bool): Responsive breakpoint
"""
def __init__(self, children=None, brand=None, brand_href=None, links=None, links_left=None,
fluid=False, color=None, dark=None, light=None, fixed=None, sticky=None,
expand="lg", style=None, class_name=None, **kwargs): ...Breadcrumb navigation component for showing page hierarchy.
class Breadcrumb:
"""
Breadcrumb navigation for page hierarchy.
Args:
items (list): List of breadcrumb dictionaries with "label", "href", "active" keys
id (str): Component identifier
style (dict): Inline CSS styles
class_name (str): Additional CSS classes
"""
def __init__(self, items=None, id=None, style=None, class_name=None, **kwargs): ...Tab navigation component for organizing content into switchable panels.
class Tabs:
"""
Tab navigation for organizing content panels.
Args:
children: Tab components
id (str): Component identifier for callbacks
active_tab (str): ID of currently active tab
style (dict): Inline CSS styles
class_name (str): Additional CSS classes
"""
def __init__(self, children=None, id=None, active_tab=None, style=None, class_name=None, **kwargs): ...Individual tab component for use within Tabs.
class Tab:
"""
Individual tab for use within Tabs component.
Args:
children: Tab content/panel
label (str): Tab label text
tab_id (str): Unique identifier for this tab
disabled (bool): Disable this tab
label_style (dict): Styles for tab label
label_class_name (str): CSS classes for tab label
active_label_style (dict): Styles for active tab label
active_label_class_name (str): CSS classes for active tab label
style (dict): Inline CSS styles for tab content
class_name (str): Additional CSS classes for tab content
"""
def __init__(self, children=None, label=None, tab_id=None, disabled=False,
label_style=None, label_class_name=None, active_label_style=None,
active_label_class_name=None, style=None, class_name=None, **kwargs): ...Pagination component for navigating through multiple pages of content.
class Pagination:
"""
Pagination component for page navigation.
Args:
id (str): Component identifier for callbacks
active_page (int): Currently active page number
max_value (int): Maximum page number
first_last (bool): Show first/last page buttons
previous_next (bool): Show previous/next buttons
fully_expanded (bool): Show all page numbers
size (str): Size - "sm", "lg"
style (dict): Inline CSS styles
class_name (str): Additional CSS classes
"""
def __init__(self, id=None, active_page=1, max_value=1, first_last=False,
previous_next=False, fully_expanded=False, size=None,
style=None, class_name=None, **kwargs): ...import dash_bootstrap_components as dbc
from dash import html
navbar = dbc.Navbar([
dbc.Container([
dbc.NavbarBrand("My App", href="/"),
dbc.Nav([
dbc.NavItem(dbc.NavLink("Home", href="/")),
dbc.NavItem(dbc.NavLink("About", href="/about")),
dbc.NavItem(dbc.NavLink("Contact", href="/contact")),
], navbar=True),
])
], color="primary", dark=True)from dash import callback, Input, Output, State
navbar = dbc.Navbar([
dbc.Container([
dbc.Row([
dbc.Col(dbc.NavbarBrand("Brand", href="/")),
dbc.Col(dbc.NavbarToggler(id="navbar-toggler")),
], align="center", no_gutters=True),
dbc.Collapse([
dbc.Nav([
dbc.NavItem(dbc.NavLink("Home", href="/")),
dbc.NavItem(dbc.NavLink("Products", href="/products")),
dbc.NavItem(dbc.NavLink("Services", href="/services")),
], navbar=True),
], id="navbar-collapse", navbar=True),
])
], color="dark", dark=True)
@callback(
Output("navbar-collapse", "is_open"),
[Input("navbar-toggler", "n_clicks")],
[State("navbar-collapse", "is_open")],
)
def toggle_navbar_collapse(n, is_open):
if n:
return not is_open
return is_open# Pre-configured simple navbar
simple_navbar = dbc.NavbarSimple(
brand="Company Name",
brand_href="/",
links=[
{"label": "Home", "href": "/"},
{"label": "About", "href": "/about"},
{"label": "Contact", "href": "/contact"},
],
color="primary",
dark=True,
)breadcrumb = dbc.Breadcrumb(
items=[
{"label": "Home", "href": "/"},
{"label": "Products", "href": "/products"},
{"label": "Electronics", "href": "/products/electronics"},
{"label": "Smartphones", "active": True},
]
)from dash import callback, Input, Output
tabs = dbc.Tabs([
dbc.Tab(label="Tab 1", tab_id="tab-1"),
dbc.Tab(label="Tab 2", tab_id="tab-2"),
dbc.Tab(label="Tab 3", tab_id="tab-3", disabled=True),
], id="tabs", active_tab="tab-1")
tab_content = html.Div(id="tab-content")
@callback(
Output("tab-content", "children"),
[Input("tabs", "active_tab")]
)
def render_tab_content(active_tab):
if active_tab == "tab-1":
return html.P("Content for Tab 1")
elif active_tab == "tab-2":
return html.P("Content for Tab 2")
return html.P("No content available")from dash import callback, Input, Output
pagination = dbc.Pagination(
id="pagination",
active_page=1,
max_value=10,
first_last=True,
previous_next=True,
fully_expanded=False,
)
content = html.Div(id="page-content")
@callback(
Output("page-content", "children"),
[Input("pagination", "active_page")]
)
def update_page_content(page):
return html.P(f"Content for page {page}")# Sidebar-style vertical navigation
sidebar_nav = dbc.Nav([
dbc.NavItem(dbc.NavLink("Dashboard", href="/dashboard", active=True)),
dbc.NavItem(dbc.NavLink("Users", href="/users")),
dbc.NavItem(dbc.NavLink("Settings", href="/settings")),
dbc.NavItem(dbc.NavLink("Reports", href="/reports")),
], vertical=True, pills=True)# Fixed to top
fixed_navbar = dbc.Navbar([
dbc.NavbarBrand("Fixed Top"),
dbc.Nav([
dbc.NavItem(dbc.NavLink("Link", href="#")),
], navbar=True),
], color="primary", dark=True, fixed="top")
# Sticky to top
sticky_navbar = dbc.Navbar([
dbc.NavbarBrand("Sticky Top"),
dbc.Nav([
dbc.NavItem(dbc.NavLink("Link", href="#")),
], navbar=True),
], color="secondary", dark=True, sticky="top")Install with Tessl CLI
npx tessl i tessl/pypi-dash-bootstrap-components