Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set TextField height material-ui

index.js

import React from 'react' import TextField from '@material-ui/core/TextField' import style from './style' import withStyles from 'hoc/withStyles' import { connect } from 'react-redux'  class SearchField extends React.Component {   constructor (props) {     super(props)     this.onChange = this.onChange.bind(this)   }    onChange (event) {     const { dispatcher } = this.props     this.props.dispatch(dispatcher(event.target.value))     event.preventDefault()   }    render () {     const { classes, placeholder } = this.props     return (       <TextField          label={placeholder}          placeholder={placeholder}         InputProps={{ classes: { input: classes.resize } }}         className={classes.textField}         margin="normal"         autoFocus={true}          variant="outlined"          onChange={this.onChange}       />     )   } }  export default withStyles(style)(connect()(SearchField)) 

style.js

export default function () {   return {     container: {       display: 'flex',       flexWrap: 'wrap'     },     textField: {       width: 'auto'     },     resize: {       fontSize: 11     }   } } 

https://material-ui.com/api/text-field/

How can I change TextField height? I can't find it in the documentation. When I try to change it directly in CSS it works incorrectly (it looks like this - selected height on the screen 26px).

What should I do?

like image 263
Andrey Radkevich Avatar asked Dec 19 '18 15:12

Andrey Radkevich


People also ask

How do I change TextField height in material UI?

To set the TextField height React Material UI, we can set the InputProps prop of the TextField to an object that has the classes property. to call makeStyles with a function that returns an object with the classes with height styles.

How do I change the TextField size in Materialui?

To change font size of text field in React Material UI, we can set the InputProps and the InputLabelProps prop to set the font size of the input box and the input label respectively. to set InputProps and InputLabelProps to { style: { fontSize: 40 } } so that the input box and the label both have font size 40px.

How do I change TextField style in MUI?

To style a React Material UI text field, we can call the makeStyles function with a function that returns an object that specifies the styles. Then we can set the InputProps prop of the TextField to specify the styles of the input element in the text field.

How do I change the material size in UI?

Material-UI Icon Size There are two ways to update the size of the icon: use the fontSize prop available on the icon or set the font-size CSS style. These are both options whether the icon is inside a button or independent of a button.


1 Answers

You can try out adding the size="small" which is mentioned in the Textfield API

<TextField variant="outlined" size="small" / > 
like image 190
SAUMITRA KUMAR Avatar answered Sep 28 '22 10:09

SAUMITRA KUMAR