简体   繁体   English

如何自定义材质ui select

[英]How customize material ui select

I'm trying to customize material-ui dropdown, to make it something like this, here is the link https://codesandbox.io/s/busy-black-2fgdn?file=/src/App.js ,我正在尝试自定义material-ui下拉列表,使其成为这样,这里是链接https://codesandbox.io/s/busy-black-2fgdn?file=/src/App.js

if I write 1 in the input (from) it selects the option that starts with 1 instead of writing in input, if none of the options starts with the number entered in the input then it writes in the input,如果我在输入(从)中写入 1,它会选择以 1 开头的选项而不是在输入中写入,如果没有选项以输入中输入的数字开头,则它会在输入中写入,

Use Autocomplete with freeSolo as a prop.使用带有freeSoloAutocomplete作为道具。 check the docs here => https://mui.com/components/autocomplete/#free-solo在此处查看文档 => https://mui.com/components/autocomplete/#free-solo

const dataList = [
  { title: "10-100", value: "10-100" },
  { title: "100-200", value: "100-200" },
  { title: "200-300", value: "200-300" },
  { title: "300-400", value: "300-400" }
];
...

<Autocomplete
    id="free-solo-demo"
    freeSolo
    options={dataList.map(option => option.title)}
    renderInput={params => <TextField {...params} label="select or type" />}
/>

code sandbox => https://codesandbox.io/s/winter-cloud-y401t?file=/src/App.js代码沙箱 => https://codesandbox.io/s/winter-cloud-y401t?file=/src/App.js

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM