Material Dioxus
Material Dioxus is a components library wrapper around Google's
Material Web Components
for the Dioxus framework. Only the dioxus-web
renderer is supported.
Example
use MatButton;
use *;
rsx! ;
Getting started
Installation
Cargo.toml
:
Material icons and a Material font must be imported for full functionality.
Dioxus.toml
:
[]
= [
"https://fonts.googleapis.com/css?family=Roboto:300,400,500",
"https://fonts.googleapis.com/css?family=Material+Icons&display=block",
# ...
]
Feature flags
There is one cargo feature for each component:
button
circular-progress
checkbox
circular-progress-four-color
icon-button
fab
formfield
icon
radio
switch
dialog
list
textfield
textarea
The all-components
feature enables all components.
Additionally, there are two features related to theming.
theming
&emdash; Provides aMatTheme
component for setting a color theme.palette
&emdash; Provides constants for the material color palette (automatically enabled bytheming
).
The full
feature enables all features.
Theming
These components respect the theming applied to Material Web Components using stylesheets. Learn about how to theme Material Web Components.
For convenience, the theming
feature provides a MatTheme
component, which
takes a few colors and sets all required CSS variables. Just include that in the
root of your application once.
Event handling
Due to lifetime limitations of the normal Dioxus event handlers, material-dioxus
cannot make use of them. The exposed events instead use a custom callback type.
For simple buttons that are never disabled you can also just wrap them in a
span
and use a normal event handler on that. For example
use *;
use MatButton;
Documentation
Full API documentation can be found here. Demos of components can be found here.