react-md
is a React component library that aims to aid in creating an
accessible web application following the rules outlined at w3.org, using the
material design specifications for design, and styles provided by SCSS
files. This page is targeted towards developers that have an existing app that
should be updated to use react-md
. If you do not have an app initialized
already or a new user, I recommend the creating a new app documentation
instead.
First, let's install react-md
and sass
:
npm install --save react-md
npm install --save-dev sass
Or if you prefer yarn:
yarn add react-md
yarn add --dev sass
Since
react-md
requires hook support, you'll also need to ensure thatreact
andreact-dom
are at least version 16.8 or higher.
Once react-md
and sass
have been installed, you'll want to include the base
react-md
styles. First, create a src/index.scss
file and generate the
styles:
@use "react-md" as *;
@include react-md-utils;
Next, update your src/index.js
file to include the index.scss
file before
all other imports:
12345678+import './index.scss';
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
ReactDOM.render(<App />, document.getElementById('root'));
Note: the default styles take a decent amount of time to compile, check out the Advanced Installation for additional info on speeding this process up.
Now that the base styles have been included, we'll also need to add the Roboto
font. This can be done through Google Fonts. Update your public/index.html
to include a link to the Roboto stylesheet:
123456 <!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
+ <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:400,500:700&display=swap" />
The
Roboto
font is not required as the font for your app. If you'd like to use a different font, check out the customizing your theme guide.
We're almost there! The last step is to include the Material Icons font so the
default font icons work throughout the app. Update public/index.html
one last
time and add the icon font:
1234567 <!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
+ <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:400,500:700&display=swap" />
Well now that you've setup the basics for your first react-md
styled app,
you'll probably be interested in:
react-md
and
explains why all the demos and other guides will be using them.react-md
and seeing the components
they provide.