/Inputs
Inputs • CSS
Focus Field
An input with a clean animated focus treatment.
Installation
Terminal
npx shadcn@latest add @microkit/focus-inputCode
TypeScript component
1import "./focus-field.css";23export function FocusField() {4return (5<label className="demo-input">6<span>Project name</span>7<input placeholder="e.g. microkit-web" />8</label>9);10}
CSS
1.demo-input {2width: 210px;3display: block;4}5.demo-input span {6display: block;7margin: 0 0 7px;8color: light-dark(#69727f,#9298a1);9font: 10px ui-monospace, SFMono-Regular, Menlo, monospace;10}11.demo-input input {12width: 100%;13border: 1px solid light-dark(#cbd2dc,#363a42);14border-radius: 5px;15background: light-dark(#ffffff,#15171b);16padding: 8px;17color: light-dark(#262d38,#e8ebee);18font-size: 11px;19outline: 0;20box-shadow: 0 0 0 0 #f9731600;21transition: border-color .32s cubic-bezier(.22, 1, .36, 1), box-shadow .32s cubic-bezier(.22, 1, .36, 1);22}23.demo-input input:focus {24border-color: #f97316;25box-shadow: 0 0 0 3px #f9731625;26}27@media (prefers-reduced-motion: reduce) {28.demo-input input {29transition: none;30}31}