Dash Mantine Components
Dash Mantine Components (DMC) is an extensive Python library offering over 100 customizable components for Plotly Dash applications, based on the Mantine React library. It provides consistent styling, theming, and full support for light and dark modes, facilitating the creation of feature-rich and accessible dashboards. The library maintains an active development pace with frequent minor releases for bug fixes and new features, and major versions often aligning with upstream Mantine releases.
Warnings
- breaking All Dash Mantine Components applications MUST be wrapped in `dmc.MantineProvider`. This component is crucial for enabling global styles, themes, and dark/light mode functionality across all child components.
- breaking Major version updates of `dash-mantine-components` (e.g., 0.x to 2.x) often align with major Mantine React library releases. These can introduce significant breaking changes, API alterations, or prop removals. Always consult the official migration guides for specific versions.
- deprecated The `DatesProvider` component no longer supports the `timezone` option. All date values should be passed as strings. Using `timezone` will result in an error or unexpected behavior.
- gotcha When using light/dark mode, a 'flash' of the incorrect theme might occur on initial page load or refresh. This happens before Dash mounts and applies the theme.
- gotcha For Dash versions prior to 3.0, it was necessary to explicitly set the React version to 18.2.0 for `dash-mantine-components` to function correctly.
Install
-
pip install dash-mantine-components
Imports
- dmc
import dash_mantine_components as dmc
- Dash
from dash import Dash
- MantineProvider
import dash_mantine_components as dmc app.layout = dmc.MantineProvider([...])
Quickstart
import dash_mantine_components as dmc
from dash import Dash, html
app = Dash(__name__)
app.layout = dmc.MantineProvider(
[dmc.Text("Hello, Dash Mantine Components!"), dmc.Button("Click me!")]
)
if __name__ == "__main__":
app.run_server(debug=True)