Skip to main content

Dash Material Design components for the Noos platform.

Project description

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

:warning: 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};

:warning: 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;

:heavy_exclamation_mark: 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:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dash_material_components-2.2.2.tar.gz (3.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dash_material_components-2.2.2-py3-none-any.whl (3.8 MB view details)

Uploaded Python 3

File details

Details for the file dash_material_components-2.2.2.tar.gz.

File metadata

  • Download URL: dash_material_components-2.2.2.tar.gz
  • Upload date:
  • Size: 3.8 MB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for dash_material_components-2.2.2.tar.gz
Algorithm Hash digest
SHA256 6f0487ebf53239191459accb5a8291b865369765cbd29ed519e31a609675fe08
MD5 ca15cbfc59ee7eef87ae7cd0d9c452b4
BLAKE2b-256 ddb7b43fd1df368903fdde95bcf4089b3e7e1d3048120cb8ac3cdbeae9b8eb24

See more details on using hashes here.

File details

Details for the file dash_material_components-2.2.2-py3-none-any.whl.

File metadata

  • Download URL: dash_material_components-2.2.2-py3-none-any.whl
  • Upload date:
  • Size: 3.8 MB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for dash_material_components-2.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e190851d67300dd93fc081b8172768ce7fab4060ce968467ea986fddda2d5bb1
MD5 c5dc0dd184e6a4eafb38d780ab34d1fb
BLAKE2b-256 3207ea7ec8d377c45d5802475d36d2bd3d277463b31168c86877a2858a8ab359

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page