Text field
A labelled input that sits in a soft well, with a ring when focused by keyboard.
Options
Code
import "./text-field.css";
export function TextField({ label, ...props }) {
return (
<label className="dh-field">
<span>{label}</span>
<input {...props} />
</label>
);
}.dh-field {
display: inline-flex;
flex-direction: column;
gap: 0.45em;
color: var(--dh-fg, #171717);
font-size: 1em;
text-align: left;
}
.dh-field span {
font-size: 0.85em;
color: var(--dh-muted, #5c5c5c);
}
.dh-field input {
width: 15em;
height: 2.6em;
padding: 0 0.85em;
border: 0;
border-radius: 0.65em;
background: var(--dh-well, #ededeb);
color: inherit;
font: inherit;
outline: none;
transition: box-shadow 150ms cubic-bezier(0.23, 1, 0.32, 1);
}
.dh-field input::placeholder {
color: var(--dh-faint, #8a8a8a);
}
.dh-field input:focus-visible {
box-shadow: 0 0 0 2px var(--dh-faint, #8a8a8a);
}<label class="dh-field">
<span>Email</span>
<input type="email" placeholder="[email protected]" />
</label>.dh-field {
display: inline-flex;
flex-direction: column;
gap: 0.45em;
color: var(--dh-fg, #171717);
font-size: 1em;
text-align: left;
}
.dh-field span {
font-size: 0.85em;
color: var(--dh-muted, #5c5c5c);
}
.dh-field input {
width: 15em;
height: 2.6em;
padding: 0 0.85em;
border: 0;
border-radius: 0.65em;
background: var(--dh-well, #ededeb);
color: inherit;
font: inherit;
outline: none;
transition: box-shadow 150ms cubic-bezier(0.23, 1, 0.32, 1);
}
.dh-field input::placeholder {
color: var(--dh-faint, #8a8a8a);
}
.dh-field input:focus-visible {
box-shadow: 0 0 0 2px var(--dh-faint, #8a8a8a);
}Text field is a Figma component
- Open it in Figma.
- Copy the component (Cmd or Ctrl + C).
- Paste it into your own file.