react-md
React material design - An accessible React component library built from the Material Design guidelines in Sass
Top Related Projects
Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
An enterprise-class UI design language and React UI library
Bootstrap components built with React
⚡️ Simple, Modular & Accessible UI Components for your React Applications
A utility-first CSS framework for rapid UI development.
Quick Overview
React-MD is a React component library that implements Google's Material Design principles. It provides a set of customizable and accessible UI components for building modern web applications with a consistent and attractive design language.
Pros
- Comprehensive set of Material Design components
- Highly customizable with Sass variables and mixins
- Accessibility-focused with ARIA support
- TypeScript support for improved developer experience
Cons
- Learning curve for developers new to Material Design
- Large bundle size if using the entire library
- Less frequent updates compared to some other React UI libraries
- Some components may require additional configuration for advanced use cases
Code Examples
- Basic Button component usage:
import { Button } from 'react-md';
function MyComponent() {
return (
<Button>Click me</Button>
);
}
- Using a TextField with a label:
import { TextField } from 'react-md';
function MyForm() {
return (
<TextField
id="username"
label="Username"
placeholder="Enter your username"
/>
);
}
- Creating a simple dialog:
import { Button, DialogContent, DialogFooter, DialogHeader, useDialog } from 'react-md';
function MyDialog() {
const { visible, toggle } = useDialog();
return (
<>
<Button onClick={toggle}>Open Dialog</Button>
<DialogContent visible={visible} onRequestClose={toggle}>
<DialogHeader>My Dialog</DialogHeader>
<p>This is the dialog content.</p>
<DialogFooter>
<Button onClick={toggle}>Close</Button>
</DialogFooter>
</DialogContent>
</>
);
}
Getting Started
To start using React-MD in your project, follow these steps:
- Install the package:
npm install react-md
- Import the CSS (or Sass) in your main application file:
import 'react-md/dist/react-md.min.css';
- Use React-MD components in your application:
import React from 'react';
import { Button, Text } from 'react-md';
function App() {
return (
<div>
<Text type="headline-4">Welcome to React-MD</Text>
<Button>Get Started</Button>
</div>
);
}
export default App;
Competitor Comparisons
Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
Pros of Material-UI
- Larger community and more frequent updates
- Extensive component library with advanced features
- Better TypeScript support and documentation
Cons of Material-UI
- Steeper learning curve due to complexity
- Larger bundle size, potentially impacting performance
- More opinionated design, less flexibility for customization
Code Comparison
Material-UI:
import { Button } from '@mui/material';
<Button variant="contained" color="primary">
Click me
</Button>
React-MD:
import { Button } from 'react-md';
<Button theme="primary" themeType="contained">
Click me
</Button>
Both libraries offer similar component APIs, but Material-UI tends to have more props and customization options. React-MD aims for simplicity and ease of use, while Material-UI provides more advanced features and flexibility.
Material-UI is generally better suited for large-scale applications with complex UI requirements, while React-MD may be preferable for smaller projects or teams looking for a simpler implementation of Material Design principles.
Ultimately, the choice between these libraries depends on project requirements, team expertise, and desired level of customization.
An enterprise-class UI design language and React UI library
Pros of Ant Design
- Larger community and more extensive ecosystem
- More comprehensive component library with a wider range of UI elements
- Better internationalization support and built-in localization
Cons of Ant Design
- Heavier bundle size due to its extensive feature set
- Less flexibility in customization compared to React-MD's modular approach
- Steeper learning curve for developers new to the library
Code Comparison
Ant Design button example:
import { Button } from 'antd';
const MyComponent = () => (
<Button type="primary">Click me</Button>
);
React-MD button example:
import { Button } from 'react-md';
const MyComponent = () => (
<Button primary>Click me</Button>
);
Both libraries offer similar basic functionality, but Ant Design provides more built-in variants and options out of the box, while React-MD focuses on simplicity and customization.
Ant Design is a more comprehensive UI library with a larger community and extensive component set, making it suitable for large-scale projects. React-MD, on the other hand, offers a more lightweight and flexible approach, allowing for easier customization and potentially faster development for smaller projects or teams that prefer a more modular architecture.
Bootstrap components built with React
Pros of React-Bootstrap
- Larger community and more widespread adoption, leading to better support and resources
- Closer alignment with Bootstrap's original design, making it familiar for Bootstrap users
- More comprehensive set of components out-of-the-box
Cons of React-Bootstrap
- Less customizable and flexible compared to React-MD's Material Design approach
- May have a steeper learning curve for developers not familiar with Bootstrap
- Potentially larger bundle size due to including full Bootstrap functionality
Code Comparison
React-Bootstrap:
import { Button } from 'react-bootstrap';
<Button variant="primary">Click me</Button>
React-MD:
import { Button } from 'react-md';
<Button theme="primary">Click me</Button>
Both libraries offer similar component-based approaches, but React-MD uses a theme
prop instead of variant
. React-MD also tends to have more customizable props for fine-tuning component behavior and appearance.
Overall, React-Bootstrap is better suited for projects that want to maintain Bootstrap's look and feel, while React-MD offers more flexibility and a Material Design aesthetic. The choice between them depends on project requirements and team preferences.
⚡️ Simple, Modular & Accessible UI Components for your React Applications
Pros of Chakra UI
- More extensive component library with a wider range of pre-built UI elements
- Better accessibility support out of the box, including ARIA attributes and keyboard navigation
- More active community and frequent updates, leading to better long-term support
Cons of Chakra UI
- Steeper learning curve due to its more complex API and extensive customization options
- Larger bundle size, which may impact initial load times for applications
Code Comparison
Chakra UI:
import { Button, Box } from "@chakra-ui/react"
function Example() {
return (
<Box>
<Button colorScheme="blue">Click me</Button>
</Box>
)
}
React MD:
import { Button } from "react-md"
function Example() {
return (
<div>
<Button theme="primary">Click me</Button>
</div>
)
}
Both libraries offer a similar approach to creating UI components, but Chakra UI provides more built-in styling options and a more extensive theming system. React MD, on the other hand, has a simpler API that may be easier for beginners to grasp quickly.
A utility-first CSS framework for rapid UI development.
Pros of Tailwind CSS
- Highly customizable with a utility-first approach
- Smaller bundle size due to purging unused styles
- Faster development with pre-built utility classes
Cons of Tailwind CSS
- Steeper learning curve for developers new to utility-first CSS
- Can lead to longer class names and potentially cluttered HTML
- Less opinionated, requiring more design decisions from developers
Code Comparison
react-md example:
import { Button } from 'react-md';
<Button primary>Click me</Button>
Tailwind CSS example:
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
Click me
</button>
Summary
Tailwind CSS offers a utility-first approach with high customizability and potentially smaller bundle sizes, while react-md provides pre-built components with a Material Design look. Tailwind CSS may have a steeper learning curve but offers more flexibility, whereas react-md provides a more opinionated and consistent design out of the box. The choice between the two depends on project requirements, team preferences, and desired level of customization.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
react-md
Create an accessible React application with the material design specifications and Scss.
- Installing packages - How to install related components and packages within react-md for building your application
- Creating a new app - How to create a new app with react-md
- Using a GitHub template - Create a new repo from a GitHub template including reasonable react-md defaults and Next.js.
- Examples with Build Tools - View and download examples of using ReactMD with build tools such as create-react-app, Next.js, and Gatsby
- Customizing your theme - How to implement a different theme for your React application
- Full documentation - All the remaining documentation along with every single guide, API Reference, and examples
- Library Size - The UMD bundle size for the entire
react-md
library and sizes for some of the pre-built css files.
Highlights/Features
- Matches the accessibility guidelines from www.w3.org
- Low level customizable components
- Easily themeable on a global and component level
- Uses css variables for dynamic themes with fallbacks for older browsers
- Out of the box dark theme mode support
- Out of the box left-to-right and right-to-left language support
- UMD Bundles and pre-compiled css available on https://unpkg.com (see more information here)
- Written and maintained in Typescript
Creating a new project
Check out the examples folder to see completed examples with different build tools such as Next.js, Gatsby, and create-react-app.
First use create-react-app to create your project:
npx create-react-app my-app
cd my-app
npm start
npx comes with npm 5.2+ and higher, if you have an older version you will need to install
create-react-app
globally instead
Or with yarn
:
yarn create react-app my-app
cd my-app
NOTE: You can also add the
--typescript
flag to bootstrap a react-app with typescript support
Next, install react-md
and sass
:
npm install --save react-md sass
Next, create a src/App.scss
file to include all the react-md
styles and
import the App.scss
file in the src/App.js
:
@use "react-md" as *;
// this will include all the styles from react-md
@include react-md-utils;
+import './App.scss';
import logo from './logo.svg';
import './App.css';
Finally, update the public/index.html
to include the Roboto
font and the
Material Icons font icons stylesheets from Google fonts:
<meta charset="utf-8" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<!--
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:300,400,500,700|Material+Icons">
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
- <body>
+ <body class="rmd-typography">
Once you have the styles, fonts, and font icons setup, you can start creating
components from react-md. It is generally recommended to update your base
src/App.js
to include some default configuration components:
import './App.scss';
-import logo from './logo.svg';
-import './App.css';
-
-function App() {
- return (
- <div className="App">
- <header className="App-header">
- <img src={logo} className="App-logo" alt="logo" />
- <p>
- Edit <code>src/App.js</code> and save to reload.
- </p>
- <a
- className="App-link"
- href="https://reactjs.org"
- target="_blank"
- rel="noopener noreferrer">
- Learn React
- </a>
- </header>
- </div>
- );
-}
+import {
+ Configuration,
+ Layout,
+ useLayoutNavigation,
+ Typography,
+ Button,
+} from 'react-md';
+
+// see @react-md/layout package for info on the main navigation
+const routes = {};
+function App() {
+ return (
+ <Configuration>
+ <Layout
+ title="My Title"
+ navHeaderTitle="My Nav Title"
+ treeProps={...useLayoutNavigation(routes, pathname)}
+ >
+ <Typography type="headline-4">Hello, world!</Typography>
+ <Button theme="primary">Example button</Button>
+ </Layout>
+ </Configuration>
+ );
+}
export default App;
More information can be found on the documentation site's page about creating projects
Library Size
The base react-md
package (non-scoped) is the only package that also provides
pre-built css themes and a UMD bundle. If you are interested in seeing what an
estimated size for this library, check out the results below:
yarn dev-utils libsize
The gzipped UMD bundle sizes are:
- dist/umd/react-md.production.min.js 92.51 kB
- dist/umd/react-md-with-font-icons.production.min.js 211.46 kB
- dist/umd/react-md-with-svg-icons.production.min.js 211.5 kB
The min and max gzipped CSS bundle sizes are:
- themes/react-md.grey-red-700-light.min.css 18.08 kB
- themes/react-md.lime-teal-200-dark.min.css 18.15 kB
Contributing
Please read the contributing guidelines if you would like to contribute.
Top Related Projects
Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
An enterprise-class UI design language and React UI library
Bootstrap components built with React
⚡️ Simple, Modular & Accessible UI Components for your React Applications
A utility-first CSS framework for rapid UI development.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot