Getting Started with React

Memory Icons can be used in React with our first-party @mdi/react module.

npm install @mdi/react @pictogrammers/memory
Demo MaterialDesign-React on GitHub

Usage

import React, { Component } from 'react'; import Icon from '@mdi/react'; import { memoryAccount } from '@pictogrammers/memory'; class App extends Component { render() { return ( <Icon path={memoryAccount} title="User Profile" size={1} horizontal vertical rotate={90} color="red" spin /> ); } };
View Example App on CodeSandbox

Props

PropPropTypesDefaultDetails
pathstringrequiredSVG path data from @pictogrammers/memory
titlestring, nullnullA11y <title>{title}</title>
descriptionstring, nullnullA11y <desc>{desc}</desc>
sizenumber, stringnull{size * 1.5}rem, '1em', '24px'
horizontalboolfalseFlip Horizontal
verticalboolfalseFlip Vertical
rotatenumber0degrees 0 to 360
colorstringcurrentColorCSS color values, such as rgb(), rgba(), #000, etc
spinbool, numberfalsetrue = 2s, {spin}s

Styling

Applying a className attribute is usually the easiest solution. The example below demonstrates using SCSS to style the icons.

In most cases it may be a good idea to set a base size. Assuming a 16px base font-size in most themes applying 1.5rem will make the icon a 24px.

svg { width: 1.5rem; }

For more specific styling apply classes. To make selection of layers easier use the nth-child selector.

// For <Icon className="custom-class" /> svg.custom-class { path { fill: blue; } } // For <Stack className="custom-class"> svg.custom-class { // First layer (behind) path:nth-child(1) { fill: blue; } // Second layer (infront) path:nth-child(2) { fill: red; } }

Accessibility

Making icons accessible can be done through the title prop. If for some rare reason more information is required a description field can also be used.

By leaving off the title prop an icon is assumed to be presentation only. These will be ignored by screen readers. This is ideal for icon buttons or areas where text next to the icon suffices.

<p><Icon path={memoryAccount} /> User Profile</p> <p><Icon path={memoryAccount} title="User Profile" /></p> <button aria-label="User Profile"><Icon path={memoryAccount} /></button>