RMWC Elevation component
npm install @rmwc/elevationElevation is the relative distance between two surfaces along the z-axis.
- Module @rmwc/elevation
- Import styles:
- Using CSS Loader
- import '@rmwc/elevation/styles';
- Or include stylesheets
- '@material/elevation/dist/mdc.elevation.css'
- MDC Docs: https://material.io/develop/web/components/elevation/
``jsx`
<>
{Array(25)
.fill(undefined)
.map((val, i) => (
{i}dp
))}
>
`jsx
function Example() {
const [elevation, setElevation] = React.useState(0);
return (
transition
onMouseOver={() => setElevation(24)}
onMouseOut={() => setElevation(0)}
>
Hover Me {elevation}dp
);
}
`
You can avoid adding extra DOM nodes by using the wrap prop on elevation. This will apply the classes directly to the child component. Additionally, Elevation is simply a className, so you can achieve the same effect by adding className="mdc-elevation--z15".
`jsx`
Wrapped!
| Name | Type | Description |
|------|------|-------------|
| transition | boolean | Allows for smooth transitions between elevations when the z value changes. |wrap
| | boolean | Allows the elevation classes to be merged onto the child component instead of creating an new DOM node. |z
| | string \| number` | A number from 0 - 24 for different levels of elevation |