Skip to content

Input 輸入 ​

輸入框用來收集文字,尺寸對齊 Button,並支援密碼、多行、清除、前後綴、狀態與圓角。

示範 ​

基礎

綁定 value,並以 e.detail.value 監聽 input。

值:(空)

尺寸

尺寸與 Button 一致:sm、md、lg。

密碼

type="password" 會在後綴區加入顯示/隱藏切換。

多行文字

type="textarea" 會渲染多行控制項;以 rows 設定高度。

可清除

clearable 在有值且可互動時顯示清除按鈕。

前後綴

使用 prefix 與 suffix 插槽放置裝飾。內建清除與密碼切換會渲染在 suffix 插槽之後。
https://$USD

狀態

以 status 顯示驗證回饋:success、warning 或 error。

圓角

設定 round 可得到全圓角外觀。

停用/唯讀

disabled 會阻擋互動;readonly 可聚焦但無法編輯。

API ​

Input Props ​

PropTypeDefault
type'text' | 'password' | 'textarea''text'
size'sm' | 'md' | 'lg''md'
valuestring''
placeholderstring''
disabledbooleanfalse
readonlybooleanfalse
clearablebooleanfalse
roundbooleanfalse
status'success' | 'warning' | 'error' | ''''
rowsnumber3
namestring''

Input Slots ​

NameDescription
prefix前方裝飾
suffix後方裝飾(位於清除/密碼切換之前)

Input Events ​

NameDescription
input值變更(輸入或清除);bubbles;composed: true;detail: { value: string }
change類似原生 change(失焦/提交或清除);bubbles;composed: true;detail: { value: string }

CSS Parts ​

PartDescription
base外層表面
input原生 <input> 或 <textarea>
prefixprefix 插槽容器
suffixsuffix 插槽與內建控制項容器
clear清除按鈕
password-toggle顯示/隱藏密碼按鈕