简体   繁体   English

如何更改单选按钮 material-ui 上的颜色

[英]How to change color on radio button material-ui

import { createMuiTheme, ThemeProvider } from "@material-ui/core";

const theme = createMuiTheme({
  palette: {
    primary: {
      main: "#5E9C60",
    },
  },
});

const RadioButton = ({ category, handlerForCategory }) => {
  return (
    <ThemeProvider theme={theme}>
      <RadioGroup
        value={category}
        onChange={(e) => handlerForCategory(e.target.value)}
      >
        <FormControlLabel
          value="Eating out"
          control={<Radio />}
          
        />

i what to change red color to green color on readio button, and i do not know how, i little use a createMuiTheme but did't wrok我如何在 readio 按钮上将红色更改为绿色,我不知道如何,我很少使用 createMuiTheme 但没有工作

You need to set the color of the radio to be primary to match the primary color from the theme.您需要将收音机的颜色设置为主要颜色以匹配主题的主要颜色。

control={<Radio color='primary'/>}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM