the*_*rer 3 javascript frontend reactjs material-ui material-table
您好,我在我的项目中使用材质表,我想知道如何更改材质 ui 自动完成中选项的字体大小。谢谢
import React from 'react';
import TextField from '@material-ui/core/TextField';
import Autocomplete from '@material-ui/lab/Autocomplete';
export default function ComboBox() {
return (
<Autocomplete
id="combo-box-demo"
options={top100Films}
getOptionLabel={(option) => option.title}
style={{ width: 300 }}
renderInput={(params) => <TextField {...params} label="Combo box" variant="outlined" />}
/>
);
}
// Top 100 films as rated by IMDb users. http://www.imdb.com/chart/top
const top100Films = [
{ title: 'The Shawshank Redemption', year: 1994 },
{ title: 'The Godfather', year: 1972 },
];
Run Code Online (Sandbox Code Playgroud)
您需要将 renderOptions 与您想要的组件一起使用。
<Autocomplete
id="combo-box-demo"
options={top100Films}
renderOption={(option) => (
<Typography style={{ fontSize: "1.5rem" }}>{option.title}</Typography>
)}
getOptionLabel={(option) => option.title}
style={{ width: 300 }}
renderInput={(params) => (
<TextField
{...params}
label="Combo box"
variant="outlined"
inputProps={{ ...params.inputProps, style: { fontSize: "1rem" } }}
/>
)}
/>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4174 次 |
| 最近记录: |