FORM & INPUT
图标前后缀输入Icon Affix Input
输入框内嵌前置图标和后缀提示(如域名、单位、显隐密码的眼睛)。
中英对照
- 中文
- 图标前后缀输入
- 英文
- Icon Affix Input
- 别名
- 带图标输入框、Prefix / Suffix Input
- 一句话
- 输入框内嵌前置图标和后缀提示(如域名、单位、显隐密码的眼睛)。
效果预览
🔍搜索项目、成员或文档…
¥1,280CNY
nova.dev/👁
适合用在哪
搜索框、金额输入、网址输入、密码框。
不适合:前后缀都是可点击复杂操作(搜索、筛选、提交)挤在同一框里:热区会乱;长域名或长单位文案也会把输入区挤没。
和相近模式的区别
浮动标签输入Floating Label Input
浮动标签占上沿空间;前后缀占左右。金额/网址/密码框优先前后缀,登录邮箱可用浮动标签。
搜索下拉高亮Search with Highlighted Results
搜索下拉是结果面板模式;图标前后缀只解决输入框内部装饰与单位,不含联想列表。
容易踩的坑
- 边框和焦点样式写在 input 上而不是容器的 :focus-within,聚焦时光晕只包住一半。
- 密码显隐的眼睛图标没有 aria-label 和 aria-pressed,读屏用户不知道当前状态。
- 前缀图标不设 pointer-events:none,点击图标区域无法聚焦输入框。
设计提示词 · Prompt
图标前后缀输入(Icon Affix Input):外层容器承担边框、圆角、聚焦光晕(container 上做 :focus-within 样式,input 本身无边框),内部横向排列——前置图标(16px、灰)+ 自适应 input(无边框透明底)+ 可选后缀。后缀三种典型:单位文字(¥ / % / kg)、固定域名(.nova.dev,用灰色不可编辑文字)、操作图标(密码显隐的眼睛、清除按钮)。整体高度 40-48px。图标颜色必须比文字浅两阶,避免抢输入内容的戏。
Icon Affix Input: the outer container takes the border, border radius and focus glow (style the container with :focus-within; the input itself has no border); inside, items are laid out horizontally — leading icon (16px, gray) + flexible input (borderless, transparent background) + optional suffix. Three typical suffixes: unit text (¥ / % / kg), a fixed domain (.nova.dev, in gray non-editable text), or an action icon (eye for password visibility, clear button). Overall height 40-48px. Icon color must be two steps lighter than the text so it doesn't upstage the input content.
可复制 CSS
自包含的最小实现,粘贴到空白页面即可生效;类名可以按项目规范改名。
/* 边框在容器;:focus-within 光晕 */
.affix {
display: flex;
align-items: center;
gap: 8px;
width: min(360px, 100%);
height: 44px;
padding: 0 12px;
border: 1px solid #d1d5db;
border-radius: 10px;
background: #fff;
}
.affix:focus-within {
border-color: #4f46e5;
box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}
.affix__ic {
font-size: 16px;
color: #9ca3af;
line-height: 1;
}
.affix input {
flex: 1;
min-width: 0;
height: 100%;
border: 0;
outline: 0;
background: transparent;
font: 15px/1 system-ui, sans-serif;
color: #111827;
}
.affix__suffix {
font: 13px/1 system-ui, sans-serif;
color: #9ca3af;
white-space: nowrap;
}
演示 HTML 结构
<div class="s d-affixwrap"> <div class="d-affix"><span class="d-affix__ic">🔍</span>搜索项目、成员或文档…</div> <div class="d-affix"><span class="d-affix__ic">¥</span><span style="color:var(--i-tx)">1,280</span><span class="d-affix__suffix">CNY</span></div> <div class="d-affix"><span style="color:var(--i-tx)">nova.dev/</span><span class="d-affix__ic" style="margin-left:auto">👁</span></div> </div>
常见问题
图标前后缀输入的英文是什么?
图标前后缀输入的英文是 Icon Affix Input。常见英文别名还包括 Prefix / Suffix Input。
Icon Affix Input 的中文是什么?
Icon Affix Input 的中文是「图标前后缀输入」。常见中文别名还包括 带图标输入框。输入框内嵌前置图标和后缀提示(如域名、单位、显隐密码的眼睛)。
密码显隐按钮怎么做无障碍?
用 button type="button",aria-label 在「显示密码 / 隐藏密码」间切换,并用 aria-pressed 表达当前态;不要只靠眼睛图标颜色。
高度为什么是 40–48px?
示例 44px。过矮触控困难,过高在密集表单里浪费纵向空间;图标约 16px 且比正文浅两阶,避免抢输入内容。
常见搭配
同一页面里经常和「图标前后缀输入」一起出现的模式,可以收藏后用「组合收藏为整页提示词」一起交给 AI。