性能
需注意帧率: 平均 60 fps,p5 59.5 · 长任务: 0 个,共 0 毫秒,最长 0 毫秒 · 源码 gzip 6.8 KB · 运行时 158 KB
Label inputMIT输入框Bencho
由 Lorenzo Cabra 制作的输入框 React 组件。依据 MIT 许可从 Bencho 原样收录,此处为实时预览。
质量报告
等级和分数来自构建或测试时跑过的自动检查。没跑过的项目会标成「未检测」,不会填假数据。
帧率: 平均 60 fps,p5 59.5 · 长任务: 0 个,共 0 毫秒,最长 0 毫秒 · 源码 gzip 6.8 KB · 运行时 158 KB
问题 0 · 读屏: 通过
没有持续动效
无溢出
帧率和长任务是在无界面的 Chromium 里用软件 WebGL 测的,只适合在本站组件之间比较,不代表真机表现。
不适用:静止时没有可见动画;由悬停触发的动画没有测试。
没有 axe-core 违规。

检测于 2026年11月15日 · 数据来自自动脚本,不是手工填写。
按实际尺寸显示。
复制内容以许可声明开头,使用代码时请保留。
<div id="root"></div>:root{--bg:#f6f4f0;--ink:#17181a;--background:40 20% 96%;--foreground:24 10% 8%;--card:0 0% 100%}html,body{min-height:100%;margin:0;background:var(--bg);color:var(--ink)}html,body{height:100%;overflow:hidden}body{display:grid;place-items:center}#root{display:grid;place-items:center;max-width:100%;max-height:100%;box-sizing:border-box;padding:16px;color:hsl(var(--foreground))}#root.full{width:100%;height:100%;padding:0}@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation-play-state:paused!important;transition-duration:0s!important}}
/*
MIT License
Copyright (c) 2026 Lorenzo Cabra
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---
Not covered by this licence: the Bencho name and the goat mark, and the
photographs shown on bencho.dev (none are included here). Third-party
material keeps its own licence; see THIRD_PARTY.md.
Icon substitution (this copy only): lucide-react (ISC) was replaced with @tabler/icons-react (MIT).
Sample photographs were replaced with Incidental AI assets. The Bencho name and goat mark are not licensed for marketing use.
*/
/* ── Bencho tokens ─────────────────────────────────────────
The custom properties the free blocks read, at the values
bencho.dev draws them with. Light by default; dark under
[data-theme="dark"] on any ancestor, or automatically with
the system setting unless [data-theme="light"] says otherwise.
Map these to your own theme rather than keeping two: a block
only ever reads the names, never the values. */
:root {
--font-ui: "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
--bg: #ffffff;
--board: #ffffff;
--card: #f7f7f6;
--surface: #f7f7f6;
--surface-2: #f1f1f0;
--surface-3: #ecebe7;
--ink: #17181a;
--ink-rgb: 23, 24, 26;
--ink-2: #3c3b37;
--ink-3: #5c5b56;
--ink-4: #6f6e68;
--ink-5: #85847e;
--on-ink: #ffffff;
--on-ink-rgb: 255, 255, 255;
--slab: #17181a;
--on-slab: #ffffff;
--slab-dark: #0e0f11;
--fill-slab: #ffffff;
--fill-on: #17181a;
--fill-on-rgb: 23, 24, 26;
--pane: var(--fill-slab);
--pane-edge: rgba(23, 24, 26, 0.08);
--pane-thumb: rgba(23, 24, 26, 0.07);
--inlay: rgba(255, 255, 255, 0.55);
--inlay-hi: rgba(23, 24, 26, 0.09);
--elev-rgb: 255, 255, 255;
--glass-rgb: 255, 255, 255;
--shadow-rgb: 23, 24, 26;
--wash: 0.06;
--pick: #0d99ff;
--signal: #2231dd;
--focus: #2231dd;
--ok: #15803d;
--ember: #b8431c;
color-scheme: light;
}
[data-theme="dark"] {
--bg: #000000;
--board: #1a1a1a;
--card: #0a0a0a;
--surface: #0f0f0f;
--surface-2: #181818;
--surface-3: #202020;
--ink: #ffffff;
--ink-rgb: 255, 255, 255;
--ink-2: #b4b4b4;
--ink-3: #9a9a9a;
--ink-4: #828282;
--ink-5: #6b6b6b;
--on-ink: #000000;
--on-ink-rgb: 0, 0, 0;
--slab: #1a1a1a;
--on-slab: #ffffff;
--slab-dark: #262626;
--fill-slab: #262626;
--fill-on: #ffffff;
--fill-on-rgb: 255, 255, 255;
--pane-edge: rgba(255, 255, 255, 0.08);
--pane-thumb: rgba(255, 255, 255, 0.07);
--inlay: rgba(255, 255, 255, 0.1);
--inlay-hi: rgba(255, 255, 255, 0.09);
--elev-rgb: 32, 32, 32;
--shadow-rgb: 0, 0, 0;
--wash: 0.09;
--pick: #3aa9ff;
--ok: #34d17a;
color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) {
--bg: #000000;
--board: #1a1a1a;
--card: #0a0a0a;
--surface: #0f0f0f;
--surface-2: #181818;
--surface-3: #202020;
--ink: #ffffff;
--ink-rgb: 255, 255, 255;
--ink-2: #b4b4b4;
--ink-3: #9a9a9a;
--ink-4: #828282;
--ink-5: #6b6b6b;
--on-ink: #000000;
--on-ink-rgb: 0, 0, 0;
--slab: #1a1a1a;
--on-slab: #ffffff;
--slab-dark: #262626;
--fill-slab: #262626;
--fill-on: #ffffff;
--fill-on-rgb: 255, 255, 255;
--pane-edge: rgba(255, 255, 255, 0.08);
--pane-thumb: rgba(255, 255, 255, 0.07);
--inlay: rgba(255, 255, 255, 0.1);
--inlay-hi: rgba(255, 255, 255, 0.09);
--elev-rgb: 32, 32, 32;
--shadow-rgb: 0, 0, 0;
--wash: 0.09;
--pick: #3aa9ff;
--ok: #34d17a;
color-scheme: dark;
}
}
/* LabelInput.css */
/*
MIT License
Copyright (c) 2026 Lorenzo Cabra
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---
Not covered by this licence: the Bencho name and the goat mark, and the
photographs shown on bencho.dev (none are included here). Third-party
material keeps its own licence; see THIRD_PARTY.md.
Icon substitution (this copy only): lucide-react (ISC) was replaced with @tabler/icons-react (MIT).
Sample photographs were replaced with Incidental AI assets. The Bencho name and goat mark are not licensed for marketing use.
*/
/* ══ Label input ═══════════════════════════════════════════
lab/LabelInput.tsx. Positioned at the root for the canvas
halo — see the note on .gen. */
.lbi {
position: relative;
font-family: var(--font-ui);
display: grid;
place-items: center;
/* room above the field for the lifted label */
padding-top: 12px;}
/* no fill: the field is only its outline */
.lbi-box {
position: relative;
background: transparent;
cursor: text;}
/* ── the outline ────────────────────────────────────────────
Always whole. At rest a hairline of grey; focused, the ink
at a hair heavier; left filled, a grey a step darker than
rest. The gap across the top is the only part that moves. */
.lbi-ring {
position: absolute;
inset: 0;
overflow: visible;
pointer-events: none;}
.lbi-ring path {
fill: none;
stroke: color-mix(in srgb, var(--fill-on, #17181a) 32%, var(--fill-slab, #ffffff));
stroke-width: 1;
stroke-linecap: butt;
transition: stroke 220ms ease, stroke-width 220ms ease;}
.lbi[data-focus="true"] .lbi-ring path {
stroke: var(--ink);
stroke-width: 1.5;}
.lbi[data-filled="true"]:not([data-focus="true"]) .lbi-ring path {
stroke: color-mix(in srgb, var(--fill-on, #17181a) 32%, var(--fill-slab, #ffffff));}
/* the gap: whole at rest, parting from its middle when the
label lifts. The dash is longer than the path so offset 0
is the whole line and -1 is none of it. */
.lbi-gap {
stroke-dasharray: 1 2;
stroke-dashoffset: 0;
transition: stroke 220ms ease, stroke-width 220ms ease,
stroke-dashoffset 420ms cubic-bezier(0.22, 1, 0.36, 1);}
.lbi[data-up="true"] .lbi-gap { stroke-dashoffset: -1; }
/* ── the label ──────────────────────────────────────────────
Its placeholder self in the middle of the field, and its
lifted self centred on the top edge — the second is the
first moved up by half the field and scaled from its left. */
.lbi-label {
position: absolute;
left: var(--lbi-x);
top: 50%;
font-size: 16px;
line-height: 1;
letter-spacing: -0.01em;
white-space: pre;
color: var(--ink-4);
transform-origin: left center;
transform: translateY(-50%);
transition: transform 420ms cubic-bezier(0.22, 1, 0.36, 1), color 220ms ease;
cursor: text;
-webkit-user-select: none;
user-select: none;}
.lbi[data-up="true"] .lbi-label {
transform: translateY(-50%) translateY(-26px) scale(0.78);
color: var(--ink-3);}
.lbi[data-focus="true"] .lbi-label { color: var(--fill-on, var(--ink)); }
.lbi-label span { display: inline-block; }
/* the hop: each letter lifts a hair and settles, one after the
next, so the word ripples as it rises */
.lbi[data-focus="true"] .lbi-label span {
animation: lbi-hop 460ms cubic-bezier(0.3, 0.7, 0.3, 1) both;
animation-delay: calc(var(--i) * 24ms);}
.lbi-field {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
padding: 0 0 0 var(--lbi-x);
border: 0;
border-radius: inherit;
background: transparent;
font: inherit;
font-size: 16px;
letter-spacing: -0.01em;
color: var(--fill-on, var(--ink));
outline: none;}
/* the reveal: the text passes through a soft blur rather than
snapping between dots and letters. Two names so a second
press restarts it. */
.lbi-field[data-flip="1"] { animation: lbi-flip-a 260ms ease-out; }
.lbi-field[data-flip="0"] { animation: lbi-flip-b 260ms ease-out; }
.lbi-eye {
position: absolute;
right: 10px;
top: 50%;
width: 30px;
height: 30px;
margin-top: -15px;
display: grid;
place-items: center;
padding: 0;
border: 0;
border-radius: 999px;
background: transparent;
color: var(--ink-4);
cursor: pointer;
transition: color 160ms ease, scale 160ms cubic-bezier(0.22, 1, 0.36, 1);}
.lbi-eye:hover { color: var(--fill-on, var(--ink)); }
.lbi-eye:active { scale: 0.96; }
/* the two icons in one place, trading places */
.lbi-eye svg {
grid-area: 1 / 1;
transition: opacity 220ms ease, scale 220ms cubic-bezier(0.22, 1, 0.36, 1), filter 220ms ease;}
.lbi-eye svg:last-child { opacity: 0; scale: 0.7; filter: blur(2px); }
.lbi-eye[data-show="true"] svg:first-child { opacity: 0; scale: 0.7; filter: blur(2px); }
.lbi-eye[data-show="true"] svg:last-child { opacity: 1; scale: 1; filter: none; }
@media (prefers-reduced-motion: reduce) {
.lbi-ring path,
.lbi-gap,
.lbi-label { transition-duration: 160ms; }
}
@media (prefers-reduced-motion: reduce) {
.lbi[data-focus="true"] .lbi-label span,
.lbi-field { animation: none; }
}
@keyframes lbi-hop {
0% { transform: translateY(0); }
38% { transform: translateY(-3px); }
100% { transform: translateY(0); }}
@keyframes lbi-flip-a { from { filter: blur(3px); opacity: 0.5; } }
@keyframes lbi-flip-b { from { filter: blur(3px); opacity: 0.5; } }
// bencho source (MIT). npm i @tabler/icons-react motion react · Tailwind CSS v4
// ── blocks/label-input/LabelInput.tsx (https://github.com/cabralorenzo/bencho/blob/c65992417427bb09e661674ffa800bef29adef49/blocks/label-input/LabelInput.tsx)
/*
MIT License
Copyright (c) 2026 Lorenzo Cabra
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
---
Not covered by this licence: the Bencho name and the goat mark, and the
photographs shown on bencho.dev (none are included here). Third-party
material keeps its own licence; see THIRD_PARTY.md.
Icon substitution (this copy only): lucide-react (ISC) was replaced with @tabler/icons-react (MIT).
Sample photographs were replaced with Incidental AI assets. The Bencho name and goat mark are not licensed for marketing use.
*/
import { useEffect, useId, useLayoutEffect, useRef, useState } from "react";
import { IconEye as Eye, IconEyeOff as EyeOff } from "@tabler/icons-react";
/* ══ Label input ══════════════════════════════════════════
A field whose label is its placeholder until you are in it.
On focus the label lifts into the top edge with a small hop
running along its letters, the outline darkens in place, and
the top line parts under the label from its middle outward.
── ONE THING MOVES ─────────────────────────────────────
It used to DRAW its outline out of the notch, both ways
round the field — and that was the field performing, which
is too much for a thing you focus forty times a day. Now the
outline is always whole; focus only changes its ink and
opens the gap. The label is the event, and the line makes
room for it.
The gap is two short paths across the notch, each from the
middle to one side, retracted from the middle outward by a
negative dash offset. */
const clamp = (v: number, a: number, b: number) => Math.min(b, Math.max(a, v));
const W = 280;
const H = 52;
/* the lifted label's size, against its resting one */
const S = 0.78;
/* the stroke sits half a stroke inside the box so none of it
is clipped by the svg's own edge */
const IN = 0.75;
export function LabelInput({
field = "Email",
/* the field's corner, px — at half the height it is a pill */
corner = 20,
/* a showcase, not a form: on a touch screen, keep the device's
keyboard down. Off by default — a real field wants its
keyboard — and the bench turns it on for its feed */
showcase = false,
}: {
field?: string;
corner?: number;
showcase?: boolean;
} = {}) {
const r = clamp(corner, 0, H / 2);
const secret = field === "Password";
const label = secret ? "Password" : "Email";
const id = `lbi-${useId().replace(/:/g, "")}`;
const [focus, setFocus] = useState(false);
const [quiet] = useState(() => showcase && typeof window !== "undefined" && window.matchMedia("(pointer: coarse)").matches);
const [value, setValue] = useState("");
const [show, setShow] = useState(false);
const [flip, setFlip] = useState(0);
const input = useRef<HTMLInputElement | null>(null);
/* the notch is the label's own width, so it is measured */
const lab = useRef<HTMLLabelElement | null>(null);
const [lw, setLw] = useState(40);
useLayoutEffect(() => {
if (lab.current) setLw(lab.current.offsetWidth);
}, [label]);
/* a different kind of field starts empty — an email left in
a password box would be shown in the clear */
useEffect(() => {
setValue("");
setShow(false);
}, [field]);
const up = focus || value.length > 0;
/* ── where the label sits, and the gap it leaves ─────────
Never inside the corner's curve: the notch has to open on
the straight part of the top edge, so a rounder field
starts its label further in. */
const lx = Math.max(14, r + 4);
const x0 = Math.max(r * 0.6, lx - 5);
const x1 = lx + lw * S + 5;
const a = r - IN;
const R = W - IN;
const B = H - IN;
const mid = W / 2;
/* the gap, as two halves from its middle to each side */
const nm = (x0 + x1) / 2;
const gapL = `M${nm},${IN} L${x0},${IN}`;
const gapR = `M${nm},${IN} L${x1},${IN}`;
/* right: from the notch, clockwise, to the bottom middle */
const right = r > 0
? `M${x1},${IN} L${W - r},${IN} A${a},${a} 0 0 1 ${R},${r} L${R},${H - r} A${a},${a} 0 0 1 ${W - r},${B} L${mid},${B}`
: `M${x1},${IN} L${R},${IN} L${R},${B} L${mid},${B}`;
/* left: from the notch, the other way round, to the same point */
const left = r > 0
? `M${x0},${IN} L${r},${IN} A${a},${a} 0 0 0 ${IN},${r} L${IN},${H - r} A${a},${a} 0 0 0 ${r},${B} L${mid},${B}`
: `M${x0},${IN} L${IN},${IN} L${IN},${B} L${mid},${B}`;
const reveal = () => {
setShow((s) => !s);
setFlip((f) => f + 1);
};
return (
<div className="lbi" data-up={up} data-focus={focus} data-filled={value.length > 0}>
<div
className="lbi-box"
style={{ width: W, height: H, borderRadius: r, "--lbi-x": `${lx}px` } as React.CSSProperties}
>
<svg className="lbi-ring" width={W} height={H} viewBox={`0 0 ${W} ${H}`} aria-hidden="true">
<path d={right} />
<path d={left} />
<path className="lbi-gap" d={gapL} pathLength={1} />
<path className="lbi-gap" d={gapR} pathLength={1} />
</svg>
<label className="lbi-label" htmlFor={id} ref={lab}>
{[...label].map((ch, i) => (
<span key={i} style={{ "--i": i } as React.CSSProperties}>{ch}</span>
))}
</label>
<input
ref={input}
id={id}
className="lbi-field"
data-flip={flip % 2}
/* ── no autofill, when it is only being shown ───────
An email or password box is an invitation: the browser
drops its saved addresses under it, a password manager
pins its badge in it, the phone offers a contact. On
the bench it is a preview, not a form, so it is a plain
text field — a hidden password masked by the font
rather than by the type — named so Safari takes it for
a search, and marked off for the managers that read
their own attribute. A real use keeps the real types. */
type={showcase ? "text" : secret && !show ? "password" : secret ? "text" : "email"}
name={showcase ? "search-preview" : undefined}
data-1p-ignore={showcase || undefined}
data-lpignore={showcase ? "true" : undefined}
data-bwignore={showcase || undefined}
data-form-type={showcase ? "other" : undefined}
autoCorrect="off"
autoCapitalize="off"
value={value}
onChange={(e) => setValue(e.target.value)}
onFocus={() => setFocus(true)}
onBlur={() => setFocus(false)}
autoComplete="off"
spellCheck={false}
/* ── no keyboard, when it is only being shown ─────
In a feed you are scrolling on a phone, a tap that
lands on the field threw the keyboard up over the
page. inputMode "none" keeps everything the block is
about — the focus, the label lifting, the gap
opening — and only tells the device not to raise its
keyboard. A mouse and a hardware keyboard are
untouched, and so is any real use of this field. */
inputMode={quiet ? "none" : undefined}
style={{
paddingRight: secret ? 48 : lx,
...(showcase && secret && !show ? { WebkitTextSecurity: "disc" } : {}),
} as React.CSSProperties}
/>
{secret && (
<button
className="lbi-eye"
type="button"
data-show={show}
/* keep focus in the field: the eye is a toggle on
what you are typing, not somewhere to go */
onPointerDown={(e) => e.preventDefault()}
onClick={reveal}
aria-label={show ? "Hide password" : "Show password"}
>
<Eye size={16} strokeWidth={2} aria-hidden="true" />
<EyeOff size={16} strokeWidth={2} aria-hidden="true" />
</button>
)}
</div>
</div>
);
}控件 · HTML · CSS · JS
直接改代码,再用控件微调,预览会随输入实时更新。

在线编辑每个组件,用控件微调,下载完整源码,复制进阶提示词。
一次性 $49占位价格
测试模式:不会真实扣款。
免费:预览、复制按钮和课程说明。
可见的标签、安静的边框和清楚的焦点状态引导输入。
搜索、登录和短文本字段。
调高度、边框颜色和焦点光晕。
把 Bencho (github.com/cabralorenzo/bencho)(MIT)中的「浮动标签输入」组件加入我的 React + Tailwind CSS 应用。源文件:https://github.com/cabralorenzo/bencho/blob/c65992417427bb09e661674ffa800bef29adef49/blocks/label-input/LabelInput.tsx。可见的标签、安静的边框和清楚的焦点状态引导输入。 适用场景:搜索、登录和短文本字段。 可调参数:调高度、边框颜色和焦点光晕。 支持浅色与深色主题,遵循 prefers-reduced-motion。保留 MIT 许可声明。
更完整的提示词,包含调参、无障碍和接入步骤。