跳到主要內容跳到主要內容

InputAdornmentAPI

React InputAdornment 元件的 API 參考文件。瞭解此匯出模組的 props、CSS 和其他 API。

示範

Import

import InputAdornment from '@mui/material/InputAdornment';
// or
import { InputAdornment } from '@mui/material';

閱讀關於最小化套件大小的指南,以了解差異。

Props

原生元件的 props 也可使用。

名稱類型預設值描述
position*'end'
| 'start'
-

此裝飾應相對於 Input 出現的位置。

childrennode-

元件的內容,通常是 IconButton 或字串。

classesobject-

覆寫或擴充套用至元件的樣式。

請參閱下方CSS 類別 API 以取得更多詳細資訊。

componentelementType-

用於根節點的元件。字串(用於 HTML 元素)或元件。

disablePointerEventsboolfalse

停用根節點上的指標事件。這允許裝飾的內容在點擊時聚焦 input

disableTypographyboolfalse

如果 children 是字串,則停用在 Typography 元件中包裝。

sxArray<func
| object
| bool>
| func
| object
-

允許定義系統覆寫以及其他 CSS 樣式的系統 prop。

請參閱 `sx` 頁面 以取得更多詳細資訊。

variant'filled'
| 'outlined'
| 'standard'
-

要使用的 variant。注意:如果您使用的是 TextField 元件或 FormControl 元件,則不必手動設定此項。

ref 會轉發到根元素。

主題預設 props

您可以使用 MuiInputAdornment 透過主題變更此元件的預設 props。

CSS 類別

這些類別名稱對於使用 CSS 設定樣式很有用。它們在觸發特定狀態時套用至元件的插槽。

類別名稱規則名稱描述
.MuiInputAdornment-disablePointerEventsdisablePointerEvents如果 disablePointerEvents={true},則套用至根元素的樣式。
.MuiInputAdornment-filledfilled如果 variant="filled",則套用至根元素的樣式。
.MuiInputAdornment-hiddenLabelhiddenLabel如果裝飾在內部使用,則套用樣式.
.MuiInputAdornment-outlinedoutlined如果 variant="outlined",則套用至根元素的樣式。
.MuiInputAdornment-positionEndpositionEnd如果 position="end",則套用至根元素的樣式。
.MuiInputAdornment-positionStartpositionStart如果 position="start",則套用至根元素的樣式。
.MuiInputAdornment-rootroot套用至根元素的樣式。
.MuiInputAdornment-sizeSmallsizeSmall如果裝飾在內部使用,則套用樣式.
.MuiInputAdornment-standardstandard如果 variant="standard",則套用至根元素的樣式。

您可以使用下列其中一個自訂選項覆寫元件的樣式

原始碼

如果您在本頁中找不到資訊,請考慮查看元件的實作以取得更多詳細資訊。