material-ui

Dock App Bar to top of window in react material ui

时间秒杀一切 提交于 2019-12-06 03:03:24
In React material ui, how do you make app bar fixed so that it stays fixed while the rest of the page scrolls? Just add a position: fixed !important; css (inline or with external css) to your AppBar component. The !important is needed if you use external css to force overriding the style defined in material-ui. Don't forget to set margin-top to your content because it will get pushed to the top. Don't know if this feature is just new but you don't need the code above. Just add a position="fixed" attribute to your <AppBar /> return ( <div className={classes.root}> <AppBar position="fixed">

Getting started with material-ui

北城以北 提交于 2019-12-06 02:25:35
问题 Seems to me the well-kept secret is the material-ui, a web framework that uses Google's Material Design UI, plus React. I think it is a fantastic combination, and the future. However, it is also a well well-kept secret on how to use it. The Getting started guide at http://material-ui.com/#/get-started is not for normal Joe, but only for a tiny fraction of people that might understand it. Moreover, the questions here, like How to use material-ui framework?, material ui Installation configure,

How to change tabs width in material UI

こ雲淡風輕ζ 提交于 2019-12-06 01:26:29
I am using material UI tabs v0.20.0 for display content in tabular format. Tabs are taking full width. I have attached screenshot of expected and current output . Expected output Current Output Please let me know solution for same. Thanks in advance If you want tabs of fixed width, you need to override the root css class passed to the Tab component, where you have to override both the minWidth and width attributes. Example: const Component = ({ classes }) => ( <Tabs value={0}> <Tab classes={{ root: classes.tab }} label="One" /> <Tab classes={{ root: classes.tab }} label="Two" /> </Tabs> ); //

material ui next dialog textfield underline color

纵饮孤独 提交于 2019-12-06 01:24:45
How can I change the underline color of a textfield inside a dialog with my secondary palette color? I couldn't do it since the documentation it's quite confusing Assuming you are using material-ui-next, you can use overrides in createMuiTheme . import { MuiThemeProvider, createMuiTheme } from 'material-ui/styles'; const theme = createMuiTheme({ overrides: { MuiInput: { underline: { '&:before': { //underline color when textfield is inactive backgroundColor: 'red', }, '&:hover:not($disabled):before': { //underline color when hovered backgroundColor: 'green', }, } } } }); Then wrap you app with

How to override styles for material-ui TextField component without using the MUIThemeProvider?

跟風遠走 提交于 2019-12-05 22:47:25
How would I hide / remove the underline in a TextField component without using the following code: const theme = createMuiTheme({ overrides: { MuiInput: { underline: { '&:hover:not($disabled):before': { backgroundColor: 'rgba(0, 188, 212, 0.7)', }, }, }, }, }); I would like to do it with props and according to the docs: https://material-ui.com/api/input/ I should be able to change the underline prop, but it does not work. This is how you do it: <TextField id="name" label="Name" value={this.state.name} margin="normal" InputProps={{disableUnderline: true}} /> How did I figure it out? You have

Material UI v1 table with scroll (overflow: scroll)

拜拜、爱过 提交于 2019-12-05 20:27:42
How to create table with scroll overflow in Material UI v1 (v1-beta currently)? In component demos in MUI documentation there is no such example. In all of the Table examples, there is a class applied to the div containing the Table that configures horizontal scrolling. It isn't apparent unless you're viewing the documentation with a sufficiently small viewport. (see BasicTable.js ): const styles = theme => ({ paper: { width: '100%', marginTop: theme.spacing.unit * 3, overflowX: 'auto', }, }); The paper class is applied to the root element: function BasicTable(props) { const classes = props

How to override material-ui MenuItem selected background color?

醉酒当歌 提交于 2019-12-05 18:39:25
Currently I am struggling with setting the background color of a MenuItem component which is selected to a different color. (without having to using !important to force it) The component code: <MenuItem classes={{ root: this.props.classes.root, selected: this.props.classes.selected }} value={10}> Alfabetical </MenuItem> This is the css: const homePageStyle = (theme) => ({ root: { width: "300px" }, selected: { backgroundColor: "turquoise !important", color: "white", fontWeight: 600 } }); What do I want to achieve? I would like to set the backgroundColor of the MenuItem without having to set the

How to add multiple Material UI palette colors

帅比萌擦擦* 提交于 2019-12-05 16:08:05
问题 I'm trying to establish my own palette colors to match my branding in Material UI. So far I can only get the primary and secondary colors to work when applied as the background color to buttons. When I add my own variable names or use "accent" as shown as an example from Material UI's website, the button defaults to grey. Here is my MyTheme.js code: import { createMuiTheme } from 'material-ui/styles'; import purple from 'material-ui/colors/purple'; export default createMuiTheme({ palette: {

Dispatch a Redux action with the subsequent action as payload to show a snackbar or dialog of Material UI

旧巷老猫 提交于 2019-12-05 13:58:24
问题 I'm using React with Redux and Material UI to build a webapp. The webapp is made of several pages and components. I know that a snackbar or dialog should be directly connected to what the user is doing. However, I'd like to make the snackbar and dialog independent on the pages and components. A use case therefore is displaying a message like background synchronization of your data failed and an action retry now . My idea was to render the snackbar on a page called RootFrame , which is used to

Material-UI Style Override?

两盒软妹~` 提交于 2019-12-05 13:17:23
I'm updating my app from Material-UI v1 to v2. I'm trying to use a style override to set the color of a selected <BottomNavigationAction> element. const styles = { bottomNavStyle: { position: 'fixed', left: '0px', bottom: '0px', height: '50px', width: '100%', zIndex: '100' }, '&$selected': { color: "#00bcd4" //<==trying to add this color to selected items }, }; class bottom_nav extends Component { state = { selectedIndex: -1, }; handleChange = (event, value) => { this.setState({value}); }; render() { const { classes } = this.props; return ( <Paper className={classes.bottomNavStyle}>