6 | {% block size_warning %}{% endblock %}
7 |
10 | {% block content %}{% endblock %}
11 |
12 |
13 |
Source Code
14 |
19 |
20 | This code is available
21 | in the examples directory of our GitHub
22 | repository.
23 |
24 |
{% block code %}{% endblock %}
27 |
28 |
29 | {% endblock %}
30 |
--------------------------------------------------------------------------------
/docs/components_page/components/card/sizing/grid.py:
--------------------------------------------------------------------------------
1 | import dash_bootstrap_components as dbc
2 | from dash import html
3 |
4 | first_card = dbc.Card(
5 | dbc.CardBody(
6 | [
7 | html.H5("Card title", className="card-title"),
8 | html.P("This card has some text content, but not much else"),
9 | dbc.Button("Go somewhere", color="primary"),
10 | ]
11 | )
12 | )
13 |
14 |
15 | second_card = dbc.Card(
16 | dbc.CardBody(
17 | [
18 | html.H5("Card title", className="card-title"),
19 | html.P(
20 | "This card also has some text content and not much else, but "
21 | "it is twice as wide as the first card."
22 | ),
23 | dbc.Button("Go somewhere", color="primary"),
24 | ]
25 | )
26 | )
27 |
28 |
29 | cards = dbc.Row(
30 | [
31 | dbc.Col(first_card, width=4),
32 | dbc.Col(second_card, width=8),
33 | ]
34 | )
35 |
--------------------------------------------------------------------------------
/docs/components_page/components/dropdown/direction.py:
--------------------------------------------------------------------------------
1 | import dash_bootstrap_components as dbc
2 |
3 | items = [
4 | dbc.DropdownMenuItem("First"),
5 | dbc.DropdownMenuItem(divider=True),
6 | dbc.DropdownMenuItem("Second"),
7 | ]
8 |
9 | dropdown = dbc.Row(
10 | [
11 | dbc.Col(
12 | dbc.DropdownMenu(
13 | label="Dropdown (default)", children=items, direction="down"
14 | ),
15 | width="auto",
16 | ),
17 | dbc.Col(
18 | dbc.DropdownMenu(label="Dropstart", children=items, direction="start"),
19 | width="auto",
20 | ),
21 | dbc.Col(
22 | dbc.DropdownMenu(label="Dropend", children=items, direction="end"),
23 | width="auto",
24 | ),
25 | dbc.Col(
26 | dbc.DropdownMenu(label="Dropup", children=items, direction="up"),
27 | width="auto",
28 | ),
29 | ],
30 | justify="between",
31 | )
32 |
--------------------------------------------------------------------------------
/docs/components_page/components/form/simple.py:
--------------------------------------------------------------------------------
1 | import dash_bootstrap_components as dbc
2 | from dash import html
3 |
4 | email_input = html.Div(
5 | [
6 | dbc.Label("Email", html_for="example-email"),
7 | dbc.Input(type="email", id="example-email", placeholder="Enter email"),
8 | dbc.FormText(
9 | "Are you on email? You simply have to be these days",
10 | color="secondary",
11 | ),
12 | ],
13 | className="mb-3",
14 | )
15 |
16 | password_input = html.Div(
17 | [
18 | dbc.Label("Password", html_for="example-password"),
19 | dbc.Input(
20 | type="password",
21 | id="example-password",
22 | placeholder="Enter password",
23 | ),
24 | dbc.FormText(
25 | "A password stops mean people taking your stuff", color="secondary"
26 | ),
27 | ],
28 | className="mb-3",
29 | )
30 |
31 | form = dbc.Form([email_input, password_input])
32 |
--------------------------------------------------------------------------------
/docs/components_page/components/layout/order_offset.py:
--------------------------------------------------------------------------------
1 | import dash_bootstrap_components as dbc
2 | from dash import html
3 |
4 | row = html.Div(
5 | [
6 | dbc.Row(
7 | dbc.Col(
8 | html.Div("A single, half-width column"),
9 | width={"size": 6, "offset": 3},
10 | )
11 | ),
12 | dbc.Row(
13 | [
14 | dbc.Col(
15 | html.Div("The last of three columns"),
16 | width={"size": 3, "order": "last", "offset": 1},
17 | ),
18 | dbc.Col(
19 | html.Div("The first of three columns"),
20 | width={"size": 3, "order": 1, "offset": 2},
21 | ),
22 | dbc.Col(
23 | html.Div("The second of three columns"),
24 | width={"size": 3, "order": 5},
25 | ),
26 | ]
27 | ),
28 | ]
29 | )
30 |
--------------------------------------------------------------------------------
/docs/components_page/components/popover/styling.py:
--------------------------------------------------------------------------------
1 | import dash_bootstrap_components as dbc
2 | from dash import html
3 |
4 | popovers = html.Div(
5 | [
6 | dbc.Button(
7 | "Hidden Arrow",
8 | id="hide-arrow-target",
9 | className="me-1",
10 | n_clicks=0,
11 | ),
12 | dbc.Popover(
13 | "I am a popover without an arrow!",
14 | target="hide-arrow-target",
15 | trigger="legacy",
16 | hide_arrow=True,
17 | body=True,
18 | ),
19 | dbc.Button(
20 | "Offset Popover",
21 | id="offset-target",
22 | n_clicks=0,
23 | ),
24 | dbc.Popover(
25 | "I am a popover that's been offset!",
26 | target="offset-target",
27 | trigger="legacy",
28 | hide_arrow=True,
29 | offset="50,20",
30 | body=True,
31 | ),
32 | ]
33 | )
34 |
--------------------------------------------------------------------------------
/docs/components_page/components/form/dash_core.py:
--------------------------------------------------------------------------------
1 | import dash_bootstrap_components as dbc
2 | from dash import dcc, html
3 |
4 | dropdown = html.Div(
5 | [
6 | dbc.Label("Dropdown", html_for="dropdown"),
7 | dcc.Dropdown(
8 | id="dropdown",
9 | options=[
10 | {"label": "Option 1", "value": 1},
11 | {"label": "Option 2", "value": 2},
12 | ],
13 | ),
14 | ],
15 | className="mb-3",
16 | )
17 |
18 | slider = html.Div(
19 | [
20 | dbc.Label("Slider", html_for="slider"),
21 | dcc.Slider(id="slider", min=0, max=10, step=0.5, value=3),
22 | ],
23 | className="mb-3",
24 | )
25 |
26 | range_slider = html.Div(
27 | [
28 | dbc.Label("RangeSlider", html_for="range-slider"),
29 | dcc.RangeSlider(id="range-slider", min=0, max=10, value=[3, 7]),
30 | ],
31 | className="mb-3",
32 | )
33 |
34 | form = dbc.Form([dropdown, slider, range_slider])
35 |
--------------------------------------------------------------------------------
/docs/demos/theme_explorer/tabs.py:
--------------------------------------------------------------------------------
1 | import dash_bootstrap_components as dbc
2 | from dash import html
3 |
4 | from .util import make_subheading
5 |
6 | tabs = html.Div(
7 | [
8 | make_subheading("Tabs", "tabs"),
9 | dbc.Tabs(
10 | [
11 | dbc.Tab(html.P("This is tab 1", className="py-3"), label="Tab 1"),
12 | dbc.Tab(
13 | dbc.Card(
14 | [
15 | html.P(
16 | "This tab has a card!",
17 | className="card-text",
18 | ),
19 | dbc.Button("Click here", color="success"),
20 | ],
21 | body=True,
22 | ),
23 | label="Tab 2",
24 | style={"padding": "10px"},
25 | ),
26 | ]
27 | ),
28 | ],
29 | className="mb-4",
30 | )
31 |
--------------------------------------------------------------------------------
/docs/components_page/components/toast/position.py:
--------------------------------------------------------------------------------
1 | import dash_bootstrap_components as dbc
2 | from dash import Input, Output, html
3 |
4 | toast = html.Div(
5 | [
6 | dbc.Button(
7 | "Open toast",
8 | id="positioned-toast-toggle",
9 | color="primary",
10 | n_clicks=0,
11 | ),
12 | dbc.Toast(
13 | "This toast is placed in the top right",
14 | id="positioned-toast",
15 | header="Positioned toast",
16 | is_open=False,
17 | dismissable=True,
18 | icon="danger",
19 | # top: 66 positions the toast below the navbar
20 | style={"position": "fixed", "top": 66, "right": 10, "width": 350},
21 | ),
22 | ]
23 | )
24 |
25 |
26 | @app.callback(
27 | Output("positioned-toast", "is_open"),
28 | [Input("positioned-toast-toggle", "n_clicks")],
29 | )
30 | def open_toast(n):
31 | if n:
32 | return True
33 | return False
34 |
--------------------------------------------------------------------------------
/docs/components_page/components/input/components_in_labels.py:
--------------------------------------------------------------------------------
1 | import dash_bootstrap_components as dbc
2 | from dash import html
3 |
4 | flights = html.Div([html.I(className="bi bi-airplane pe-1"), "Flights"])
5 | car = html.Div([html.I(className="bi bi-car-front pe-1"), "Rental Car"])
6 | hotel = html.Div([html.I(className="bi bi-house pe-1"), "Hotel"])
7 |
8 | radioitems = html.Div(
9 | [
10 | dbc.Label("Booking"),
11 | dbc.RadioItems(
12 | options=[
13 | {"label": flights, "value": 1},
14 | {"label": car, "value": 2},
15 | {"label": hotel, "value": 3},
16 | ],
17 | value=1,
18 | id="radioitems-with-icons",
19 | ),
20 | ]
21 | )
22 |
23 | checkbox = dbc.Checkbox(
24 | id="checkbox-with-link",
25 | label=html.Div(["I agree to the ", html.A("Terms and Conditions", href="#")]),
26 | value=False,
27 | )
28 |
29 | components_in_labels = html.Div([radioitems, html.Hr(), checkbox])
30 |
--------------------------------------------------------------------------------
/docs/demos/theme_explorer/alert.py:
--------------------------------------------------------------------------------
1 | import dash_bootstrap_components as dbc
2 | from dash import html
3 |
4 | from .util import make_subheading
5 |
6 | alerts1 = dbc.Col(
7 | [
8 | dbc.Alert("This is a primary alert", color="primary"),
9 | dbc.Alert("This is a secondary alert", color="secondary"),
10 | dbc.Alert("This is a success alert! Well done!", color="success"),
11 | dbc.Alert("This is a warning alert... be careful...", color="warning"),
12 | ],
13 | md=6,
14 | xs=12,
15 | )
16 |
17 | alerts2 = dbc.Col(
18 | [
19 | dbc.Alert("This is a danger alert. Scary!", color="danger"),
20 | dbc.Alert("This is an info alert. Good to know!", color="info"),
21 | dbc.Alert("This is a light alert", color="light"),
22 | dbc.Alert("This is a dark alert", color="dark"),
23 | ],
24 | md=6,
25 | xs=12,
26 | )
27 |
28 | alerts = html.Div(
29 | [make_subheading("Alert", "alert"), dbc.Row([alerts1, alerts2])],
30 | className="mb-4",
31 | )
32 |
--------------------------------------------------------------------------------
/docs/run.py:
--------------------------------------------------------------------------------
1 | from werkzeug.middleware.dispatcher import DispatcherMiddleware
2 |
3 | from components_page import register_apps as register_component_apps # noqa
4 | from demos import register_apps as register_demo_apps # noqa
5 | from examples import register_apps as register_example_apps # noqa
6 | from markdown_to_html import convert_all_markdown_files # noqa
7 | from server import create_server # noqa
8 |
9 | convert_all_markdown_files()
10 |
11 | server = create_server()
12 | component_routes = register_component_apps()
13 | example_routes = register_example_apps()
14 | demo_routes = register_demo_apps()
15 | routes = {**component_routes, **example_routes, **demo_routes}
16 | application = DispatcherMiddleware(
17 | server, {slug: app.server for slug, app in routes.items()}
18 | )
19 |
20 | if __name__ == "__main__":
21 | import os
22 |
23 | from werkzeug.serving import run_simple
24 |
25 | os.environ["DBC_DOCS_MODE"] = "dev"
26 | run_simple("localhost", 8888, application, use_reloader=True)
27 |
--------------------------------------------------------------------------------
/docs/components_page/components/pagination/callback.py:
--------------------------------------------------------------------------------
1 | import dash_bootstrap_components as dbc
2 | from dash import Input, Output, dcc, html
3 |
4 | pagination = html.Div(
5 | [
6 | html.Div("Select a page", id="pagination-contents"),
7 | dbc.Pagination(id="pagination", max_value=10),
8 | html.Div("Or set the page dynamically using the slider below"),
9 | dcc.Slider(
10 | id="page-change",
11 | min=1,
12 | max=10,
13 | step=1,
14 | value=1,
15 | marks={i: str(i) for i in range(1, 11)},
16 | ),
17 | ]
18 | )
19 |
20 |
21 | @app.callback(
22 | Output("pagination-contents", "children"),
23 | [Input("pagination", "active_page")],
24 | )
25 | def change_page(page):
26 | if page:
27 | return f"Page selected: {page}"
28 | return "Select a page"
29 |
30 |
31 | @app.callback(Output("pagination", "active_page"), [Input("page-change", "value")])
32 | def change_active_page(value):
33 | return value
34 |
--------------------------------------------------------------------------------
/docs/components_page/components/popover/popover_callback.py:
--------------------------------------------------------------------------------
1 | import dash_bootstrap_components as dbc
2 | from dash import Input, Output, State, html
3 |
4 | popover = html.Div(
5 | [
6 | dbc.Button(
7 | "Toggle",
8 | id="toggle",
9 | color="success",
10 | className="me-4",
11 | n_clicks=0,
12 | ),
13 | dbc.Button("Target", id="target", color="danger", n_clicks=0),
14 | dbc.Popover(
15 | [
16 | dbc.PopoverHeader("Popover header"),
17 | dbc.PopoverBody("And here's some amazing content. Cool!"),
18 | ],
19 | id="popover",
20 | is_open=False,
21 | target="target",
22 | ),
23 | ]
24 | )
25 |
26 |
27 | @app.callback(
28 | Output("popover", "is_open"),
29 | [Input("toggle", "n_clicks")],
30 | [State("popover", "is_open")],
31 | )
32 | def toggle_popover(n, is_open):
33 | if n:
34 | return not is_open
35 | return is_open
36 |
--------------------------------------------------------------------------------
/docs/components_page/helpers.py:
--------------------------------------------------------------------------------
1 | from dash import dcc, html
2 |
3 |
4 | def HighlightedSource(source):
5 | return html.Div(
6 | dcc.Markdown(f"```python\n{source}\n```"),
7 | className="example-source-container",
8 | )
9 |
10 |
11 | def ExampleContainer(component, source):
12 | return html.Div(
13 | [
14 | html.Div(component, className="example"),
15 | HighlightedSource(source),
16 | ],
17 | className="example-container",
18 | )
19 |
20 |
21 | def load_source_with_environment(source, component_name, environment=None):
22 | """
23 | Execute a source snippet, injecting the variables specified in environment
24 |
25 | Return the local variable defined by `component_name`. This should be used
26 | for source files that need to register `@app` callbacks. In this case, be
27 | sure to pass app in the environment.
28 | """
29 | environment = environment or {}
30 | exec(source, environment)
31 | return environment[component_name]
32 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug-report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Tell us about a bug you may have identified in Dash Bootstrap Components
4 | ---
5 |
6 | Before opening:
7 |
8 | - [Search for duplicate or closed issues](https://github.com/dbc-team/dash-bootstrap-components/issues?utf8=%E2%9C%93&q=is%3Aissue)
9 | - Read the [contributing guidelines](https://github.com/dbc-team/dash-bootstrap-components/blob/main/.github/CONTRIBUTING.md)
10 |
11 | Please fill out the below information as much as possible.
12 |
13 | - dash version: `#x.x.x`
14 | - dash-bootstrap-components version: `#x.x.x`
15 | - components affected by bug:
16 |
17 | ### What is happening?
18 |
19 |
20 |
21 | ### What should be happening?
22 |
23 |
24 |
25 | ### Code
26 |
27 |
30 |
31 | ```python
32 | # your code here
33 | ```
34 |
35 | ### Error messages
36 |
37 | ```bash
38 | paste any error messages here
39 | ```
40 |
--------------------------------------------------------------------------------
/docs/components_page/components/fade/transition.py:
--------------------------------------------------------------------------------
1 | import dash_bootstrap_components as dbc
2 | from dash import Input, Output, State, html
3 |
4 | fade = html.Div(
5 | [
6 | dbc.Button(
7 | "Toggle fade",
8 | id="fade-transition-button",
9 | className="mb-3",
10 | n_clicks=0,
11 | ),
12 | dbc.Fade(
13 | dbc.Card(
14 | dbc.CardBody(
15 | html.P("This content fades in and out", className="card-text")
16 | )
17 | ),
18 | id="fade-transition",
19 | is_in=True,
20 | style={"transition": "opacity 2000ms ease"},
21 | timeout=2000,
22 | ),
23 | ]
24 | )
25 |
26 |
27 | @app.callback(
28 | Output("fade-transition", "is_in"),
29 | [Input("fade-transition-button", "n_clicks")],
30 | [State("fade-transition", "is_in")],
31 | )
32 | def toggle_fade(n, is_in):
33 | if not n:
34 | # Button has never been clicked
35 | return True
36 | return not is_in
37 |
--------------------------------------------------------------------------------
/src/components/layout/__tests__/Row.test.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @jest-environment jsdom
3 | */
4 | import React from 'react';
5 |
6 | import {render} from '@testing-library/react';
7 |
8 | import Row from '../Row';
9 |
10 | describe('Row', () => {
11 | test('renders a div with class "row"', () => {
12 | const row = render(