Skip to content

Commit

Permalink
Merge pull request mui#4034 from nathanmarks/muitheme-documentation
Browse files Browse the repository at this point in the history
[Docs] Update usage docs with muiTheme instructions
  • Loading branch information
oliviertassinari committed Apr 19, 2016
2 parents f34ddf0 + 5042657 commit b266f34
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 11 deletions.
30 changes: 27 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ specification.
Check out our [documentation site](http://www.material-ui.com/) for live examples.
It's still a work in progress, but hopefully you can see where we're headed.

**Recently Updated?** Please read the [changelog](https://github.com/callemall/material-ui/releases), this README and the documentation before posting an issue.

## Prerequisites

We recommend that you get to know [React](http://facebook.github.io/react/)
Expand Down Expand Up @@ -65,10 +67,32 @@ on how to do so.

## Usage

Using material-ui components is very straightforward.
Once material-ui is included in your project, you can use the components this way:
Material-UI components are easy to use. The quickest way to get up and running is by using the `MuiThemeProvider` to inject the theme into your application context. Following that, you can to use any of the components as demonstrated in our documentation.

```js
Here is a quick example to get you started:

**./App.js**
```jsx
import React from 'react';
import ReactDOM from 'react-dom';
import getMuiTheme from 'material-ui/styles/getMuiTheme';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import MyAwesomeReactComponent from './MyAwesomeReactComponent';

const App = () => (
<MuiThemeProvider muiTheme={getMuiTheme()}>
<MyAwesomeReactComponent />
</MuiThemeProvider>
);

ReactDOM.render(
<App />,
document.getElementById('app')
);
```

**./MyAwesomeReactComponent.js**
```jsx
import React from 'react';
import RaisedButton from 'material-ui/RaisedButton';

Expand Down
1 change: 0 additions & 1 deletion docs/src/app/components/pages/get-started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Until then, be sure to inject this plugin at the start of your app.
import injectTapEventPlugin from 'react-tap-event-plugin';

// Needed for onTouchTap
// Can go away when react 1.0 release
// Check this repo:
// https://github.com/zilverline/react-tap-event-plugin
injectTapEventPlugin();
Expand Down
37 changes: 30 additions & 7 deletions docs/src/app/components/pages/get-started/usage.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
## Usage

Using material-ui components is very straightforward.
Once material-ui is included in your project, you can use the components this way:
```js
// Basic React component that renders a Material-UI
// raised button with the text "Default"
import React from 'react'
Material-UI components are easy to use. The quickest way to get up and running is by using the `MuiThemeProvider` to inject the theme into your application context. Following that, you can to use any of the components as demonstrated in our documentation.

Here is a quick example to get you started:

**./App.js**
```jsx
import React from 'react';
import ReactDOM from 'react-dom';
import getMuiTheme from 'material-ui/styles/getMuiTheme';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import MyAwesomeReactComponent from './MyAwesomeReactComponent';

const App = () => (
<MuiThemeProvider muiTheme={getMuiTheme()}>
<MyAwesomeReactComponent />
</MuiThemeProvider>
);

ReactDOM.render(
<App />,
document.getElementById('app')
);
```

**./MyAwesomeReactComponent.js**
```jsx
import React from 'react';
import RaisedButton from 'material-ui/RaisedButton';

const MyAwesomeReactComponent = () => (
Expand All @@ -15,6 +36,8 @@ const MyAwesomeReactComponent = () => (
export default MyAwesomeReactComponent;
```

Please refer to each component's documentation page to see how they should be imported.

Notice that in the above example, we used:
```js
import RaisedButton from 'material-ui/RaisedButton';
Expand All @@ -27,7 +50,7 @@ import {RaisedButton} from 'material-ui';

This will make your build process faster and your build output smaller.
For a complete mapping of Material-UI components to `import`,
see `/lib/index.js` inside the Material-UI root directory.
see `/index.js` inside the Material-UI npm package root directory.

### Customization

Expand Down

0 comments on commit b266f34

Please sign in to comment.