How to add padding and margin to all Material-UI components?

You can use de “Spacing” in a BOX component just by importing the component first: import Box from ‘@material-ui/core/Box’; The Box component works as a “Wrapper” for the component you want to “Modify” the spacing. then you can use the next properties on the component: The space utility converts shorthand margin and padding props to … Read more

CSS pseudo selectors with MUI

I found out that the content attribute needed to be double quoted like this const styles = () => createStyles({ h: { ‘&::before’: { content: ‘”some content”‘, display: ‘block’, height: 60, marginTop: -60 } } }); and then everything worked like expected

Intercept/handle browser’s back button in React-router?

Using react-router made the job simple as such: import { browserHistory } from ‘react-router’; componentDidMount() { this.onScrollNearBottom(this.scrollToLoad); this.backListener = browserHistory.listen((loc, action) => { if (action === “POP”) { // Do your stuff } }); } componentWillUnmount() { // Unbind listener this.backListener(); }

How to style material-ui textfield

You need to add the InputProps property to the TextField. const styles = theme => ({ textField: { width: ‘90%’, marginLeft: ‘auto’, marginRight: ‘auto’, paddingBottom: 0, marginTop: 0, fontWeight: 500 }, input: { color: ‘white’ } }); JSX: <TextField id=”email” label=”Email” className={classes.textField} value={this.state.form_email} onChange={this.handle_change(‘form_email’)} margin=”normal” InputProps={{ className: classes.input, }} /> As an aside, you can … Read more

Media queries in MUI components

By using the breakpoints attribute of the theme, you can utilize the same breakpoints used for the Grid and Hidden components directly in your component. API theme.breakpoints.up(key) => media query Arguments key (String | Number): A breakpoint key (xs, sm, etc.) or a screen width number in pixels. Returns media query: A media query string … Read more

How to apply custom animation effect @keyframes in MUI?

Here is an example demonstrating the keyframes syntax within makeStyles: import React from “react”; import ReactDOM from “react-dom”; import { makeStyles } from “@material-ui/core/styles”; import Button from “@material-ui/core/Button”; import clsx from “clsx”; const useStyles = makeStyles(theme => ({ animatedItem: { animation: `$myEffect 3000ms ${theme.transitions.easing.easeInOut}` }, animatedItemExiting: { animation: `$myEffectExit 3000ms ${theme.transitions.easing.easeInOut}`, opacity: 0, transform: “translateY(-200%)” … Read more

How to make a dropdown menu open below the Appbar using Material UI?

The way I got it to work is by setting the props on the menu itself like this: <Menu id=”menu-appbar” anchorEl={anchorEl} getContentAnchorEl={null} anchorOrigin={{ vertical: ‘bottom’, horizontal: ‘center’ }} transformOrigin={{ vertical: ‘top’, horizontal: ‘center’ }} open={open} onClose={this.handleClose} className={props.classes.menu} > The positioning props (anchorOrigin, transformOrigin) come from the Popover component, see the demo: https://mui.com/material-ui/react-popover/#anchor-playground. I also had … Read more

react Material-ui, How do I know I can use onClick for button?

The Material-UI documentation does not list the standard React (native browser) events: https://facebook.github.io/react/docs/events.html#mouse-events This is because it’s expected that you are already aware of the available native events. For example, you can also use onWheel. It would be a long and redundant list if all the native events were included. As kouak explains, other props … Read more

How get data from material-ui TextField, DropDownMenu components?

Add an onChange handler to each of your TextField and DropDownMenu elements. When it is called, save the new value of these inputs in the state of your Content component. In render, retrieve these values from state and pass them as the value prop. See Controlled Components. var Content = React.createClass({ getInitialState: function() { return … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)