简体   繁体   中英

Material UI TextField customization

I сannot customize label in TextField component. Styles do not apply to label in TextField component. What am I doing wrong?

    import React, { PureComponent } from 'react'
    import { withStyles } from '@material-ui/core/styles'
    import TextField from '@material-ui/core/TextField'

    const StyledTextField = withStyles({
        root: {},
        label: {
            textTransform: 'uppercase'
        }
    })(TextField)

    class App extends PureComponent {
        render() {
            return (
                <StyledTextField
                    id='city-of-residence'
                    label='Город проживания'
                    fullWidth={true}
                    margin='normal'
                    helperText='helperText'/>
            )
        }
    }

    ReactDOM.render(<App />, document.getElementById('root'))

Expected result =)

在此处输入图片说明

Current result =(

在此处输入图片说明

hi you can use your custom react element inside label like below

 <StyledTextField
                    id='city-of-residence'
                    label={<p style={{textTransform: 'uppercase'}}>Город проживания</p>}
                    fullWidth={true}
                    margin='normal'
                    helperText='helperText'/>
            )

您可以在 css text-transform: uppercase 中使用;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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