簡體   English   中英

如何去掉MUI select組件的邊框?

[英]How to remove the border of the MUI select component?

我想自定義MUI Select組件。 基本上我只想刪除邊框或更確切地說是輪廓。 我試圖覆蓋styles,嘗試使用NativeSelect並嘗試將自定義的InputBaseSelect用作inputComponent ,但這些都不起作用。 任何幫助將非常感激。

邊框應用於OutlinedInput組件的標簽。 編輯OutlinedInput組件的 css 規則notchedOutline以移除邊框。 https://mui.com/api/outlined-input/#css

MUI 在Select組件中公開了disableUnderline屬性。 只需將其設置為true

我遵循@Bar的回答:在我的情況下,我還必須重置應用於Selectbox-shadow

對於材料 v5,

<Select sx={{ boxShadow: 'none', '.MuiOutlinedInput-notchedOutline': { border: 0 } }}>

無邊框 MUI 選擇的屏幕截圖

對我有用的是使用

  • disableUnderline刪除選擇器下方的行
  • variant="standard"去除邊框,無論選擇器是否聚焦。

設置'.MuiOutlinedInput-notchedOutline': { border: 0 }只會在未聚焦時移除選擇器的邊框。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM