gpt4 book ai didi

css - 设置TextField高度material-ui

转载 作者:技术小花猫 更新时间:2023-10-29 11:18:00 25 4
gpt4 key购买 nike

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 中更改它时,它无法正常工作(看起来 like this - 在屏幕上选择的高度为 26 像素)。

我该怎么办?

最佳答案

您可以尝试添加 Textfield API 中提到的 size="small"

<TextField variant="outlined" size="small" / >

关于css - 设置TextField高度material-ui,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53854030/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com