material-ui

What is the proper way of using the styling defined inside createMuiTheme alongside with Material-UI's useStyles?

巧了我就是萌 提交于 2020-08-10 19:29:07
问题 import React from 'react'; import Component from './components/Component'; import { createMuiTheme, makeStyles, ThemeProvider } from '@material-ui/core/styles';; const theme = createMuiTheme({ container: { width: '100%', paddingRight: '15px', paddingLeft: '15px', marginRight: 'auto', marginLeft: 'auto' }, flexColumn: { display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", } }); function App() { return ( <ThemeProvider theme={theme}> <div className="App">

How to change font color based on background color using reactJs

ぃ、小莉子 提交于 2020-08-10 05:18:50
问题 I have dynamic background of my container it will change by User so I need to set text color based of background color eg, I set black background of my container then i need to set white color for text, I am using ReactJs and material UI library for my App, please suggest some good path. 回答1: see the below sample code. import React, { useState, useEffect } from "react"; import ReactDOM from "react-dom"; import DynamicContainer from "./style"; import "./styles.css"; function App() { const

React Create a Horizontal Divider with Text In between

我是研究僧i 提交于 2020-08-09 09:55:55
问题 I need to create a React component that is a Horizontal Divider with a content like text In between. All the resources I have online is unable to help me get this done. I tried a material-ui divider by creating a Divider component and placing my text in-between like the example below: <Divider>Or</Divider> But I get the error: hr is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`. I need to achieve this in the image below: Any help will be appreciated.

React Create a Horizontal Divider with Text In between

五迷三道 提交于 2020-08-09 09:55:13
问题 I need to create a React component that is a Horizontal Divider with a content like text In between. All the resources I have online is unable to help me get this done. I tried a material-ui divider by creating a Divider component and placing my text in-between like the example below: <Divider>Or</Divider> But I get the error: hr is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`. I need to achieve this in the image below: Any help will be appreciated.

Add text to Switch formcontrol and change it in toggle using material ui

拜拜、爱过 提交于 2020-08-09 09:01:33
问题 I am using Material UI's Switch component and I want to add text inside it. Also I need to make it square in shape. How to I add text inside the Switch component. It should say on when selected and off when default. I am using Material UI's Switch inside Formcontrol in reactjs form. <FormControlLabel label="Private ? " labelPlacement="start" control={ <Switch checked={this.state.checked} onChange={this.handleChange} color='primary' /> } /> 回答1: Here is an example of how to change the text

Add text to Switch formcontrol and change it in toggle using material ui

孤人 提交于 2020-08-09 09:01:07
问题 I am using Material UI's Switch component and I want to add text inside it. Also I need to make it square in shape. How to I add text inside the Switch component. It should say on when selected and off when default. I am using Material UI's Switch inside Formcontrol in reactjs form. <FormControlLabel label="Private ? " labelPlacement="start" control={ <Switch checked={this.state.checked} onChange={this.handleChange} color='primary' /> } /> 回答1: Here is an example of how to change the text

Material UI global css variables

限于喜欢 提交于 2020-08-09 07:18:41
问题 I would like to declare some css variables that I will reuse among my components. This is how you do it with plain css: :root { --box-shadow: 0 2px 5px -1px rgba(0, 0, 0, 0.3); } That would then be used as follows: .my-class { box-shadow: var(--box-shadow); } How can I achieve the same with useStyles? I tried the following with no avail: const theme = createMuiTheme({ shadowing: { boxShadow: "0 2px 5px -1px rgba(0, 0, 0, 0.3)", } }); My main App is enclosed within <ThemeProvider theme={theme}

Material UI global css variables

不问归期 提交于 2020-08-09 07:18:07
问题 I would like to declare some css variables that I will reuse among my components. This is how you do it with plain css: :root { --box-shadow: 0 2px 5px -1px rgba(0, 0, 0, 0.3); } That would then be used as follows: .my-class { box-shadow: var(--box-shadow); } How can I achieve the same with useStyles? I tried the following with no avail: const theme = createMuiTheme({ shadowing: { boxShadow: "0 2px 5px -1px rgba(0, 0, 0, 0.3)", } }); My main App is enclosed within <ThemeProvider theme={theme}

How to change the color of Menu in material-ui

僤鯓⒐⒋嵵緔 提交于 2020-08-09 06:49:42
问题 I am using Menu from material-ui and want to change the background color. Problem is, when I give color to Menu, it changes the whole page background when the menu popper appears. And when I apply color to Menu Items, it leaves some grey shades at the top and bottom, because all these menu Items are enclosed inside a div. Problem Sandbox: https://codesandbox.io/s/material-ui-dropdown-background-color-g88e1 What's the right way to change Menu's background color? I tried createMuiTheme for

How to change the color of Menu in material-ui

淺唱寂寞╮ 提交于 2020-08-09 06:48:31
问题 I am using Menu from material-ui and want to change the background color. Problem is, when I give color to Menu, it changes the whole page background when the menu popper appears. And when I apply color to Menu Items, it leaves some grey shades at the top and bottom, because all these menu Items are enclosed inside a div. Problem Sandbox: https://codesandbox.io/s/material-ui-dropdown-background-color-g88e1 What's the right way to change Menu's background color? I tried createMuiTheme for