You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3 年之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. #### Note
  2. For *how-to* questions and other non-issues,
  3. please use [StackOverflow](http://stackoverflow.com/questions/tagged/material-ui)
  4. instead of Github issues. There is a StackOverflow tag called "material-ui"
  5. that you can use to tag your questions.
  6. # [Material-UI](http://www.material-ui.com/)
  7. [![npm package](https://img.shields.io/npm/v/material-ui.svg?style=flat-square)](https://www.npmjs.org/package/material-ui)
  8. [![Build Status](https://travis-ci.org/callemall/material-ui.svg?branch=master)](https://travis-ci.org/callemall/material-ui)
  9. [![Gitter](https://img.shields.io/badge/gitter-join%20chat-f81a65.svg?style=flat-square)](https://gitter.im/callemall/material-ui?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
  10. [![Coverage Status](https://coveralls.io/repos/github/callemall/material-ui/badge.svg?branch=master)](https://coveralls.io/github/callemall/material-ui?branch=master)
  11. [![PeerDependencies](https://img.shields.io/david/peer/callemall/material-ui.svg?style=flat-square)](https://david-dm.org/callemall/material-ui#info=peerDependencies&view=list)
  12. [![Dependencies](https://img.shields.io/david/callemall/material-ui.svg?style=flat-square)](https://david-dm.org/callemall/material-ui)
  13. [![DevDependencies](https://img.shields.io/david/dev/callemall/material-ui.svg?style=flat-square)](https://david-dm.org/callemall/material-ui#info=devDependencies&view=list)
  14. Material-UI is a set of [React](http://facebook.github.io/react/) components that implement
  15. [Google's Material Design](https://www.google.com/design/spec/material-design/introduction.html)
  16. specification.
  17. Check out our [documentation site](http://www.material-ui.com/) for live examples.
  18. It's still a work in progress, but hopefully you can see where we're headed.
  19. **Recently Updated?** Please read the [changelog](https://github.com/callemall/material-ui/releases), this README and the documentation before posting an issue.
  20. ## Required Knowledge
  21. We recommend that you get to know [React](http://facebook.github.io/react/)
  22. before diving into material-ui. Material-UI is a set of React components,
  23. so understanding how React fits into web development is important.
  24. (If you're not familiar with Node, or with the concept of Single Page Applications (SPAs),
  25. head over to the [documentation website](http://material-ui.com/#/get-started/required-knowledge)
  26. for a quick introduction before you read on.)
  27. ## Installation
  28. Material-UI is available as an [npm package](https://www.npmjs.org/package/material-ui).
  29. **Stable channel**
  30. ```sh
  31. npm install material-ui
  32. ```
  33. **Pre-release channel**
  34. ```sh
  35. npm install material-ui@next
  36. ```
  37. Please note that `@next` will only point to pre-releases; to get the latest stable release use `@latest` instead.
  38. ### React-Tap-Event-Plugin
  39. (not needed for versions 0.19.0 and higher)
  40. Some components use
  41. [react-tap-event-plugin](https://github.com/zilverline/react-tap-event-plugin) to
  42. listen for touch events because onClick is not fast enough
  43. _This dependency is temporary and will eventually go away._ Until then,
  44. be sure to inject this plugin at the start of your app.
  45. ```js
  46. import injectTapEventPlugin from 'react-tap-event-plugin';
  47. // Needed for onTouchTap
  48. // http://stackoverflow.com/a/34015469/988941
  49. injectTapEventPlugin();
  50. ```
  51. ### Roboto Font
  52. Material-UI was designed with the [Roboto](http://www.google.com/fonts/specimen/Roboto)
  53. font in mind. So be sure to include it in your project. Here are
  54. [some instructions](http://www.google.com/fonts#UsePlace:use/Collection:Roboto:400,300,500)
  55. on how to do so.
  56. ## Usage
  57. Beginning with v0.15.0, Material-UI components require a theme to be provided. 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 use any of the components as demonstrated in the documentation.
  58. Here is a quick example to get you started:
  59. **./App.js**
  60. ```jsx
  61. import React from 'react';
  62. import ReactDOM from 'react-dom';
  63. import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
  64. import MyAwesomeReactComponent from './MyAwesomeReactComponent';
  65. const App = () => (
  66. <MuiThemeProvider>
  67. <MyAwesomeReactComponent />
  68. </MuiThemeProvider>
  69. );
  70. ReactDOM.render(
  71. <App />,
  72. document.getElementById('app')
  73. );
  74. ```
  75. **./MyAwesomeReactComponent.js**
  76. ```jsx
  77. import React from 'react';
  78. import RaisedButton from 'material-ui/RaisedButton';
  79. const MyAwesomeReactComponent = () => (
  80. <RaisedButton label="Default" />
  81. );
  82. export default MyAwesomeReactComponent;
  83. ```
  84. Please refer to each component's documentation page to see how they should be imported.
  85. ## Customization
  86. We have implemented a default theme to render all Material-UI components.
  87. Styling components to your liking is simple and hassle-free. This can be
  88. achieved in the following two ways:
  89. * [Use a custom theme to style components](http://material-ui.com/#/customization/themes)
  90. * [Override individual component styles via the `style` prop](http://www.material-ui.com/#/customization/styles)
  91. ## Examples
  92. There are 2 projects that you can look at to get started. They can be found in the
  93. [examples folder](https://github.com/callemall/material-ui/tree/master/examples).
  94. These projects are basic examples that show how to consume material-ui components
  95. in your own project. The first project uses [browserify](http://browserify.org/)
  96. for module bundling and [gulp](http://gulpjs.com/) for JS task automation,
  97. while the second project uses [webpack](http://webpack.github.io/) for module bundling and building.
  98. The source code for this documentation site is also included in the repository.
  99. This is a slightly more complex project that also uses webpack, and contains
  100. examples of every material-ui component. Check out the
  101. [docs folder](https://github.com/callemall/material-ui/tree/master/docs)
  102. for build instructions.
  103. ## Roadmap
  104. The future plans and high priority features and enhancements can be found
  105. in the [ROADMAP.md](https://github.com/mui-org/material-ui/blob/v0.x/ROADMAP.md) file.
  106. ## Contribute
  107. [Material-UI](http://www.material-ui.com/) came about from our love of
  108. [React](http://facebook.github.io/react/) and
  109. [Google's Material Design](https://www.google.com/design/spec/material-design/introduction.html).
  110. We're currently using it on a project at [Call-Em-All](https://www.call-em-all.com/Careers)
  111. and plan on adding to it and making it better. If you'd like to help,
  112. check out the [docs folder](https://github.com/callemall/material-ui/tree/master/docs).
  113. We'd greatly appreciate any [contribution](https://github.com/mui-org/material-ui/blob/v0.x/CONTRIBUTING.md)
  114. you make. :)
  115. ## Thanks
  116. [<img src="https://www.browserstack.com/images/mail/browserstack-logo-footer.png" width="120">](https://www.browserstack.com/)
  117. Thank you to [BrowserStack](https://www.browserstack.com/) for providing the infrastructure that allows us to test `material-ui` in real browsers.
  118. ## License
  119. This project is licensed under the terms of the
  120. [MIT license](https://github.com/mui-org/material-ui/blob/v0.x/LICENSE)