Material UI 是一款功能很強大,界面卻十分清新簡潔的CSS框架。Material UI利用了Google的Material Design 全新設計語言。並且讓每一個UI組件都變得很獨立。所以開發人員使用Material UI也會比較簡單。和Bootstrap相似,Material UI提供了很是多常用的UI組件。除了最主要的菜單、button、滑動杆、進度條、單選框/複選框外,它還提供了一個很是有趣的日曆組件,另外還提供了一些很是有趣的圖標。css
首先咱們從最主要的看起。html
如下是一個簡單的多級下拉菜單git
代碼例如如下:github
nestedMenuItems = [ { type: mui.MenuItem.Types.NESTED, text: 'Reports', items: [ { payload: '1', text: 'Nested Item 1' }, { type: mui.MenuItem.Types.NESTED, text: 'Nested Item 2', items: [ { payload: '1', text: 'Nested Item 2.1' }, { type: mui.MenuItem.Types.NESTED, text: 'Nested Item 2.2', items: [ { payload: '1', text: 'Nested Item 2.2.1' }, { payload: '3', text: 'Nested Item 2.2.2' } ] }, { payload: '3', text: 'Nested Item 2.3' } ] }, { payload: '3', text: 'Nested Item 3' }, { type: mui.MenuItem.Types.NESTED, text: 'Nested Item 4', items: [ { payload: '1', text: 'Nested Item 4.1' }, { type: mui.MenuItem.Types.NESTED, text: 'Nested Item 4.2', items: [ { payload: '1', text: 'Nested Item 4.2.1', disabled: true }, { payload: '3', text: 'Nested Item 4.2.2' } ] }, { payload: '3', text: 'Nested Item 4.3' } ] }, { payload: '4', text: 'Nested Item 5' } ] }, { payload: '1', text: 'Audio Library'}, { payload: '2', text: 'Settings'}, { payload: '3', text: 'Logout', disabled: true} ]; <Menu menuItems={nestedMenuItems} autoWidth={false}/>
如下是一個帶圖標的垂直菜單web
代碼例如如下:npm
//iconClassName is the classname for our icon that will get passed into mui.FontIcon iconMenuItems = [ { payload: '1', text: 'Live Answer', iconClassName: 'muidocs-icon-communication-phone', number: '10' }, { payload: '2', text: 'Voicemail', iconClassName: 'muidocs-icon-communication-voicemail', number: '5' }, { payload: '3', text: 'Starred', iconClassName: 'muidocs-icon-action-stars', number: '3' }, { payload: '4', text: 'Shared', iconClassName: 'muidocs-icon-action-thumb-up', number: '12' } ]; <Menu menuItems={iconMenuItems} autoWidth={false}/>
如下是簡單的彩色button。點擊button會出現波浪擴散的動畫效果。bootstrap
代碼例如如下:框架
//Raised Buttons <RaisedButton label="Default" /> <RaisedButton label="Primary" primary={true} /> <RaisedButton label="Secondary" secondary={true} /> <div style={styles.container}> <RaisedButton primary={true} label="Choose an Image"> <input type="file" style={styles.exampleImageInput}></input> </RaisedButton> </div> <div style={styles.container}> <RaisedButton linkButton={true} href="https://github.com/callemall/material-ui" secondary={true} label="Github"> <FontIcon style={styles.exampleButtonIcon} className="muidocs-icon-custom-github"/> </RaisedButton> </div> <RaisedButton label="Disabled" disabled={true} />
如下是Material UI通過美化過的單選框和複選框學習
代碼例如如下:動畫
<RadioButtonGroup name="shipSpeed" defaultSelected="not_light"> <RadioButton value="light" label="prepare for light speed" style={{marginBottom:16}} /> <RadioButton value="not_light" label="light speed too slow" style={{marginBottom:16}}/> <RadioButton value="ludicrous" label="go to ludicrous speed" style={{marginBottom:16}} disabled={true}/> </RadioButtonGroup>
這是我的認爲最美麗的CSS日曆組件
代碼例如如下:
//Portrait Dialog <DatePicker hintText="Portrait Dialog" //Landscape Dialog <DatePicker hintText="Landscape Dialog" mode="landscape"/> // Ranged Date Picker <DatePicker hintText="Ranged Date Picker" autoOk={this.state.autoOk} minDate={this.state.minDate} maxDate={this.state.maxDate} showYearSelector={this.state.showYearSelector} />
Material UI還有很是多實用的CSS UI組件,你可以前往其官方站點下載及學習使用。