Skip to content

Instantly share code, notes, and snippets.

@ben-bradley
Last active November 22, 2016 16:18
Show Gist options
  • Save ben-bradley/5f532c4b846329cb4e72ea7a29954594 to your computer and use it in GitHub Desktop.
Save ben-bradley/5f532c4b846329cb4e72ea7a29954594 to your computer and use it in GitHub Desktop.
Create-React-App with MUI
// src/index.js
import React from 'react';
import ReactDOM from 'react-dom';
import injectTapEventPlugin from 'react-tap-event-plugin';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import App from './App';
import './index.css';
injectTapEventPlugin();
const ThemedApp = () => (
<MuiThemeProvider>
<App />
</MuiThemeProvider>
);
ReactDOM.render(
<ThemedApp />,
document.getElementById('root')
);
npm install -g create-react-app
create-react-app foobar
cd foobar
npm install --save react-tap-event-plugin material-ui material-design-icons
cp -R node_modules/material-design-icons/iconfont public/fonts/
atom .
npm start
// src/App.js
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import Card from './components/Card';
class App extends Component {
render() {
return (
<div className="App">
<link href="fonts/material-icons.css" rel="stylesheet" />
<div className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h2>Welcome to React</h2>
</div>
<div>
Hello, World!
</div>
<Card />
<p className="App-intro">
To get started, edit <code>src/App.js</code> and save to reload.
</p>
</div>
);
}
}
export default App;
// src/components/Card.js
import React from 'react';
import { Card, CardActions, CardHeader, CardText } from 'material-ui/Card';
import FlatButton from 'material-ui/FlatButton';
const CardExampleExpandable = () => (
<Card>
<CardHeader
title="Without Avatar"
subtitle="Subtitle"
actAsExpander={true}
showExpandableButton={true}
/>
<CardActions>
<FlatButton label="Action1" />
<FlatButton label="Action2" />
</CardActions>
<CardText expandable={true}>
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Donec mattis pretium massa. Aliquam erat volutpat. Nulla facilisi.
Donec vulputate interdum sollicitudin. Nunc lacinia auctor quam sed pellentesque.
Aliquam dui mauris, mattis quis lacus id, pellentesque lobortis odio.
</CardText>
</Card>
);
export default CardExampleExpandable;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment