Skip to main content

CircleCI

Dash Material Design Components

dash-material-components allows to build consistently styled dashboards with complex and reactive layouts, following Google's Material Design principles.

The library leverages MUI React components for use with Plotly Dash.

This project has been initially boostrapped thanks to the Dash plugin cookiecutter.

Quickstart

Installation

The python package is available from the PyPi repository,

pip install dash-material-components

Usage as a library

Once installed, start using the Python components exactly like you would use other Dash component libraries,

import dash

import dash_material_components as dmc


# Compose a dashboard layout
text = dmc.Typography(text="Content...", component="p", variant="body2")

section_1 = dmc.Section(
    id="section-1",
    orientation="columns",
    children=[text, text_2],
    cards=[{"title": "Card 1a", "size": 3}, {"title": "Card 1b"}]
)

section_2 = dmc.Section(
    id="section-2",
    size=3,
    children=[text, text_2],
    orientation="rows",
    cards=[{"title": "Card 2a", "size": 4}, {"title": "Card 2b"}]
)

page = dmc.Page(orientation="columns", children=[section_1, section_2])
navbar = dmc.NavBar(title="Custom dash")

layout = dmc.Dashboard(children=[navbar, page])

# Instantiate a Dash app
app = dash.Dash(__name__)
app.layout = layout

if __name__ == "__main__":
    app.run_server()

Usage in notebooks

As pre-requisite, install the Jupyter Lab extension JupyterDash,

~$ pip install jupyter-dash

Then, copy the Dash snippet above into a Jupyter notebook cell and replace the Dash class with the JupyterDash class:

from dash import Dash
# Instantiate a Dash app
app = Dash(__name__)
app.layout = layout

app.run_server(mode='jupyterlab', host="0.0.0.0", port=8001)

Local development

Structure for a Dash component project

* project/
  * python-package/             # The python package, output folder for the bundles.
    * src/                      # The javascript source directory for the components.
      * components/             # Where to put the react component classes.
      * index.js                # The index for the components exported by the bundle.
    * package.json              # JS package build commands.
    * webpack.config.js         # The webpack configs used to generate the bundles.
    * pyproject.toml            # Python package build commands.

Install dependencies

The project is shipped with off-the-shelf scripts to manage node packages as well as a set of utilities for local development. If the yarn node package manager is installed globally, install all javascript dependencies,

~$ yarn install --frozen-lockfile

⚠️ the Dash material components has only been tested against Node.js v18.

Install uv, then install the project dependencies using:

~$ uv sync --dev

Write a new React component

Compose your new Dash components in src/components and make sure the React components are exported in your package entrypoint src/index.js.

import NoosComponent from './components/NoosComponent.jsx';

export {NoosComponent};

⚠️ the Dash material components are currently using MUI v.4, with the aim to transitionning to MUI v.5 shortly.

The corresponding Python component API is auto-discovered from the React component declared Props, while the component Python docstring are automatically generated from the Props React docstrings.

/** Used to auto-generate the Python component and docstrings */
const NoosComponent = (props) => {
    const {text} = props;

    return (
        <div>
            <p>{text}</p>
        </div>
    );
}

Box.defaultProps = {
  text: 'Sample value',
};

Box.propTypes = {
  /** Used to auto-generate the Python component and docstrings */
  text: PropTypes.string,
};

export default NoosComponent;

❗ Be careful to use the correct formatting for your docstrings for them to be properly recognized.

Create a production build

Once your components have been included into your package entrypoint, run:

  • yarn build:js, to generate the JavaScript bundle dash_material_components.js
  • yarn build:py, to generate the Python class files for the components.
  • yarn build, to generate everything: the JavaScript bundles and the Python class files.

In addition to buikld scripts, the project package.json offers linter, formatter and hot-reloader:

  • yarn format, to auto-format the React component code.
  • yarn lint, to check bundle compliance with ECMA standards.
  • yarn watch, to watch the library source directory and rebuild the JavaScript bundle.

Further reading

Included below, few resources on how to extend the Dash component library:

Release files for dash-material-components 2.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dash-material-components 2.2.3
File Size Uploaded
dash_material_components-2.2.3.tar.gz 3.8 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for dash-material-components 2.2.3
File Interpreter ABI Platform
dash_material_components-2.2.3-py3-none-any.whl Python 3 none any Details

Total release size: 7.6 MB

Release files / dash_material_components-2.2.3.tar.gz

Download URL dash_material_components-2.2.3.tar.gz
Size 3.8 MB
Tags Source
SHA-256 checksum
How to use checksums
61e431d62dd6124c29a5ebd4c14ec1b564b63b2ed82a5780811b987b9cf71889
BLAKE2b-256 checksum
How to use checksums
9dee0c736464c6d7b91affbe7f16f245493826bfd8170f2ae813d8d72346717c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / dash_material_components-2.2.3-py3-none-any.whl

Download URL dash_material_components-2.2.3-py3-none-any.whl
Size 3.8 MB
Tags Python 3
SHA-256 checksum
How to use checksums
8febd8e19c269b0394dfecf3924fec22ab63cfd90a403452a7326bd10d9656a8
BLAKE2b-256 checksum
How to use checksums
93fa4f9758cf09daca1af6ad2ae727fd4f239bb14c5f9e595c9227e262159342
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

2.2.3 This release

2 release files

2.2.2

2 release files

2.2.1

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.12

2 release files

2.0.11

2 release files

2.0.9

2 release files

2.0.8

2 release files

2.0.7

2 release files

2.0.6

2 release files

2.0.5

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.2.0

2 release files

1.1.8

2 release files

1.1.7

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page