如何更改 Material ui 自动完成中选项的字体大小?

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)

Som*_*ial 5

您需要将 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)

代码沙箱

普通字体

大字体