如何更改材料UI版本5版中的选项字体大小自动完成?

发布于 2025-02-02 11:46:31 字数 669 浏览 5 评论 0原文

我想更改下拉物品的字体尺寸。

我尝试了更改字体大小的不同方式,如下所示,

更改材料UI自动完成字体尺寸?

如何要更改材料UI自动完成的选项的字体大小吗?

,但是这些方式对我不起作用,希望它们是由于它们适用于版本4。

这是我的自动完成组件。

<Autocomplete
   size="small"
   disablePortal
   options={getVisaOptions()}
   renderInput={(params) => <TextField  {...params} label="Select VISA"/>}
/>

I want to change the font size of the drop down items.

I tried different ways of changing font size as follows,

How do I change Material UI Autocomplete font size?

How to change fontsize of options in Material ui autocomplete?

But those ways are not working for me, hope it is due to they are for version 4.

Here is my Autocomplete component.

<Autocomplete
   size="small"
   disablePortal
   options={getVisaOptions()}
   renderInput={(params) => <TextField  {...params} label="Select VISA"/>}
/>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

独自←快乐 2025-02-09 11:46:31

它可以使用自定义renderoption

<Autocomplete
    size="small"
    disablePortal
    options={getVisaOptions()}
    getOptionLabel={(option) => option.label}
    renderOption={(props, option) => (
        <Box style={{fontSize: 14}} {...props}>
            {option.label}
        </Box>
    )}
    renderInput={(params) => <TextField  {...params} label="Select VISA"/>}
/>

it worked with customizing renderOption

<Autocomplete
    size="small"
    disablePortal
    options={getVisaOptions()}
    getOptionLabel={(option) => option.label}
    renderOption={(props, option) => (
        <Box style={{fontSize: 14}} {...props}>
            {option.label}
        </Box>
    )}
    renderInput={(params) => <TextField  {...params} label="Select VISA"/>}
/>
红衣飘飘貌似仙 2025-02-09 11:46:31

关于您的问题,您可以为选项字体大小设置渲染图并设置样式,这是我可以尝试的示例。

<Autocomplete
   size="small"
   disablePortal
   options={getVisaOptions()}
   renderInput={(params) => <TextField  {...params} label="Select VISA"/>}
   renderOption={(props, option) => (
             <Typography sx={{fontSize: 18}}>
                {option.label}
             </Typography>)
            }
/>

About your question, you could set renderOption and set style for the option font size, here is my example you can try.

<Autocomplete
   size="small"
   disablePortal
   options={getVisaOptions()}
   renderInput={(params) => <TextField  {...params} label="Select VISA"/>}
   renderOption={(props, option) => (
             <Typography sx={{fontSize: 18}}>
                {option.label}
             </Typography>)
            }
/>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文