css - 设置TextField高度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))
样式.js
export default function () {
return {
container: {
display: 'flex',
flexWrap: 'wrap'
},
textField: {
width: 'auto'
},
resize: {
fontSize: 11
}
}
}
https://material-ui.com/api/text-field/
我怎样才能改变TextField
高度?我在文档中找不到它。当我尝试直接在 CSS 中更改它时,它无法正常工作(看起来像这样- 屏幕上选择的高度为 26px)。
我应该怎么办?
解决方案
您可以尝试添加 Textfield API 中提到的 size="small"
<TextField variant="outlined" size="small" / >
推荐阅读
- maven - Change Maven-driven project based on Vaadin 11 to Vaadin 12 alpha version?
- javascript - 一键打开 2 个页面,但不能同时打开
- excel - 支票日是当月的最后一个工作日
- vhdl - std_logic_vector 的 VHDL 乘法
- r - 如何从 jpeg 中提取某些颜色及其位置?
- javascript - Styling Material Vue AutoComplete suggestion drop down
- laravel-5.1 - Laravel Model Factory Error: Trying to get property of non-object
- c++ - Event Handling in a Given Order
- javascript - 在javascript中模拟与数组和回调的异步
- django - 在应用程序折叠 Django 中使用静态折叠