AI輸入框生成器。

描述你的表單,MeDo 會同時生成文字輸入框與多行文字框 — 標籤、輔助文字、錯誤狀態、前綴與後綴附加元素、字數計算以及高度自動調整,全部連接到正確的無障礙屬性。

輸入框
輸入框

輸入框本身是整個元件裡最小的一部分

輸入框的大部分工作與欄位本身無關。標籤、輔助文字、錯誤提示區以及它們之間的間距才決定表單是否好用,而這些正是元件庫慣於丟給使用者的部分。於是團隊為每個表單手寫包裝標記,垂直節奏一個欄位一個欄位地偏離,最後什麼都對不齊。把標籤、說明與錯誤區域作為一個整體生成,可以一次性固定它們的關係。這同時消除了網頁表單中最常見的無障礙缺陷:錯誤訊息顯示在欄位旁邊,卻從未在程式層面與它關聯。

6 個模板

可以產生的 輸入框 模板

每個模板都是真實的提示詞,而非截圖。複製到任何 AI 編輯器,或在 MeDo 中執行,直接取得 React + Tailwind 程式碼。

BasicLabel + Field

Labeled Input With Helper Text

The baseline every other field extends. Label, field, and a message region that already occupies its line at rest so the form does not grow when an error appears.

Create a text input component with a visible label above the field, wired with a generated id and a matching for attribute rather than wrapping the input in the label. Below it, a helper text line linked through aria-describedby. Reserve the height of that line at rest so the form does not shift when an error replaces it. The field is 40px tall with an 8px radius, a 1px grey border, and a 2px focus-visible ring offset from the border. Add a required prop that sets the required attribute and appends a visually hidden "required" to the label rather than relying on an asterisk alone. Accept type, inputMode and autocomplete as props with no defaults, so each call site declares them.

在 MeDo 中試試
ErrorsValidation States

Error, Success and Warning States

Where most form bugs live. An error message rendered beside a field but never connected to it is the most common accessibility defect in web forms.

Add validation states to a text input: error with a red border, a red message replacing the helper text, aria-invalid="true", and the message linked through aria-describedby so it is announced when focus enters the field. Add success and warning states that change the border and the leading icon but keep the same message slot and line height. Never signal state by border color alone — pair every state with an icon and text. Validate on blur, then revalidate on change only once the field is already in an error state, so a half-typed email is not flagged mid-entry. Announce late server-side errors through a polite live region.

在 MeDo 中試試
AffixesAffix Slots

Prefix and Suffix Inside the Field

Search icons, currency symbols, unit suffixes, password toggles. The trap is padding — an affix rendered over the field without matching inset padding lets typed text slide underneath it.

Create a text input with optional prefix and suffix slots rendered inside the field border. Static affixes such as a currency symbol or a .com suffix get aria-hidden and muted text; interactive affixes such as a password visibility toggle or a clear button render as real buttons with their own aria-label and stay reachable by keyboard. Increase the field padding to match each affix width so typed text never slides under it. Keep the focus ring on the outer wrapper, not the bare input, so the ring surrounds the affixes too. Include a search variant with a leading magnifier and a trailing clear button that appears only when the field has a value.

在 MeDo 中試試
TextareaAutosize Textarea

Growing Textarea With a Counter

A fixed three-row box for a support message forces people to scroll inside a scroll. Growing to a cap keeps the submit button on screen.

Create a textarea that shares the label, helper text and error layout of the text input. Autosize from a three-row minimum up to eight rows, recalculating the height from scrollHeight on input after resetting it, then switch to internal scrolling at the cap so a long message cannot push the submit button off screen. Add an optional character counter in the bottom right showing used and total, turning amber at 90 percent of the limit and red at the limit, announced through a polite live region rather than on every keystroke. Disable the native resize handle only when autosizing is on, otherwise leave it available.

在 MeDo 中試試
FormattingMasked Field

Card, Phone and Date Inputs

Formatted fields where the input event rewrites the value. Get the caret handling wrong and editing the middle of a card number jumps the cursor to the end on every keystroke.

Create a formatted input for card numbers, phone numbers and expiry dates. Insert separators as the user types — spaces every four digits for cards, a slash after the month for expiry — while storing the unformatted value in state and submitting that. Preserve the caret position when the mask inserts a character mid-string, rather than letting the value reset send it to the end. Set inputMode="numeric" and the correct autocomplete token: cc-number, tel, cc-exp. Accept paste of an already-formatted value by stripping non-digits first. Validate length on blur and keep the field editable in the error state.

在 MeDo 中試試
LayoutField Group

Multi-Field Row With Shared Rhythm

City and postcode on one line, expiry and CVC side by side. The point is a single spacing scale, since per-form wrapper markup is what makes vertical rhythm drift.

Create a form field group component that lays out two or three inputs on one row using a grid, collapsing to a single column below 640px. Keep a shared vertical gap between rows and align the labels on a single baseline even when one field carries helper text and its neighbor does not, by reserving the message line in every field. Group semantically related fields in a fieldset with a legend, such as an address block, so screen readers announce the group name before each field. Let each field declare its own width in grid columns rather than a hardcoded percentage, so a postcode field can be narrower than a city field.

在 MeDo 中試試

如何自訂你的 輸入框

務必要求一個真正的標籤

佔位符並非標籤。使用者一開始輸入它就消失,中途被打斷的人會失去線索,而且大多數螢幕閱讀器把它視為可選文字。要求一個透過 <label for> 與欄位關聯的可見標籤,佔位符只用於展示 MM/YY 這類格式範例。

為錯誤訊息預留空間

若錯誤文字只在驗證失敗時出現,送出時下方欄位會向下跳動。說明輔助與錯誤區域在靜止狀態下也佔據固定行高,這樣訊息出現時表單高度不會改變。

明確說明需要的輸入類型

為每個欄位指定 type 與 inputMode:email、tel 與 numeric 會喚起不同的行動裝置鍵盤。再搭配正確的 autocomplete 權杖,例如 email、tel、current-password 與 one-time-code,瀏覽器與密碼管理員才能自動填寫表單。

決定驗證的觸發時機

每次按鍵都驗證,會在使用者寫完之前就把半個電郵地址標記為錯誤。要求在 blur 時驗證,欄位已處於錯誤狀態後再於 change 時重新驗證,這樣既能糾錯又不會一直打擾使用者。

誰在使用 輸入框 組件

註冊或登入表單

電郵與密碼欄位,後綴插槽裡帶內嵌的顯示切換,輔助文字中顯示密碼強度提示,並設定 autocomplete 權杖,讓瀏覽器提供已儲存的憑證而非空白欄位。

結帳流程

卡號、有效期與郵政編碼輸入框採用數字輸入模式,金額欄位帶貨幣前綴,並在 blur 時驗證,使輸入中的卡號不會被誤判為無效。

客服或聯絡表單

一個簡短的主題輸入框,下方是帶 1,000 字計數器的高度自動調整留言文字框,長訊息會撐開欄位,而非迫使使用者在固定框內捲動。

儀表板設定面板

密集排列的小尺寸輸入框,標籤靠左對齊,使用者無法修改的值採用 read-only 欄位,輔助文字說明每項設定的作用。

不同網站的 輸入框 方案

同一個 輸入框 組件,針對它所在網站的類型作調整。

01 / 06

SaaS Signup and Login Inputs

Two fields decide whether the account gets created, so the autocomplete tokens matter more than the styling. Set email and current-password on login and new-password on signup, or password managers offer the wrong entry and people retype credentials they already saved. Put the visibility toggle in the suffix slot as a real button, not a click handler on an icon.

輸入框 的風格與變體

挑選與頁面其餘部分相襯的變體,然後產生它。

01 / 06

Outlined Input

A 1px border on a light surface with the label above — the default that works in the widest range of layouts. Keep the focus ring offset from the border rather than replacing it, so the resting and focused widths match and the field does not appear to move on focus.

在 React、Next.js、Vue 與 Svelte 中使用 輸入框

React、Next.js、Vue 3、SvelteKit、Astro 或純 HTML —— 同一個 輸入框,六種接入方式。

01 / 06

React Input

Generate the id with useId so label association survives rendering the field twice on one page. Forward the ref so form libraries like React Hook Form can register the element directly.

src/components/Input.tsx

export const Input = forwardRef(function Input(
  { label, hint, error, ...props },
  ref
) {
  const id = useId()
  return (
    <div className="space-y-1.5">
      <label htmlFor={id}>{label}</label>
      <input id={id} ref={ref} aria-invalid={!!error}
        aria-describedby={id + '-msg'} {...props} />
      <p id={id + '-msg'}>{error ?? hint}</p>
    </div>
  )
})

如何把 輸入框 加入專案

四個步驟,從挑選 輸入框 模板到推上生產環境。

01~30s

Pick an Input Template

Scan the six templates and start from the field you actually need — labeled text input, affix slots for search or currency, autosizing textarea, or a masked card field.

02~10s

Copy the Prompt

Take the prompt into MeDo, Lovable, Bolt, v0 or Cursor. Name the type, inputMode and autocomplete token per field before you run it, since those three decide which mobile keyboard opens and whether autofill works.

03~1min

Generate and Refine

You get React + Tailwind back with a live preview. Follow up in plain English — "validate on blur only", "add a clear button in the suffix", "reserve the error line" — rather than editing the aria wiring by hand.

04~2min

Wire It to Your Form State

Register the forwarded ref with React Hook Form, Formik or a Server Action and pass the resolver error straight into the error prop. The component owns layout and aria; your form library owns the validation rules.

關於 輸入框 的常見問題

如何用AI生成表單輸入框?

在一個提示詞裡描述欄位、標籤、輔助文字與需要的狀態,例如「帶標籤、提示文字與錯誤狀態的電郵輸入框」。MeDo 會把標籤、欄位與訊息區域生成為一個元件,aria 屬性已經連接妥當。你可以在同一個提示詞裡列出多種欄位類型,取得風格一致的整套元件。

佔位符與標籤有何分別?

標籤永久標明欄位名稱,使用者輸入時依然可見。佔位符是欄位內的臨時提示文字,一輸入就消失,因此只用它當標籤會令使用者猜自己已經填了什麼。欄位名稱用標籤,佔位符只用於展示格式範例。

輸入錯誤應在輸入時顯示還是送出後顯示?

在 blur 時驗證而非每次按鍵都驗證,這樣輸入中的值不會在填寫過程中被標記為錯誤。欄位已顯示錯誤後,改為在 change 時重新驗證,值一旦有效訊息就消失。送出時驗證留給需要整個表單的檢查,例如密碼確認。

AI能生成符合無障礙標準的輸入欄位嗎?

可以。MeDo 用 for 與 id 把標籤與欄位關聯,用 aria-describedby 連接輔助文字與錯誤文字,並在驗證失敗時設定 aria-invalid。在提示詞裡提到必填欄位,它會用 required 屬性標記,而不是只依賴一個星號。

如何令多行文字框隨內容增高?

要求一個帶最小與最大行數的自動調整文字框,例如由三行增長至八行後開始捲動。高度會在每次輸入時根據 scroll height 重新計算,限制最大值可避免長訊息把送出按鈕擠出畫面。

autocomplete 屬性真的有用嗎?

有用。正確的 autocomplete 權杖能讓瀏覽器與密碼管理員一步填完欄位,這在註冊與結帳表單上能明顯降低放棄率。告訴 MeDo 每個欄位收集什麼,它便會設定對應的權杖,包括那些容易寫錯的地址與付款相關取值。