.input { @apply rounded-field border bg-field px-3 py-2 text-base text-field-foreground shadow-field outline-none placeholder:text-field-placeholder sm:text-sm; border-width: var(--border-width-field); border-color: var(--field-border); /* Current fill. States reassign `--input-bg`; variants override the three tokens. */ --input-bg: var(--color-field); --input-bg-hover: var(--color-field-hover); --input-bg-focus: var(--field-focus); /* Inset layer covers the UA autofill paint. The rest keeps shadow-field and the focus ring. */ --input-autofill-shadow: 0 0 0 1000px var(--input-bg) inset, var(--tw-inset-shadow, 0 0 #0000), var(--tw-inset-ring-shadow, 0 0 #0000), var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow, 0 0 #0000); /** * Transitions * CRITICAL: motion-reduce must be AFTER transition for correct override specificity */ transition: background-color 150ms var(--ease-smooth), border-color 150ms var(--ease-smooth), box-shadow 150ms var(--ease-out); @apply motion-reduce:transition-none; @media (hover: hover) { &:hover:not(:focus):not(:focus-visible), &[data-hovered="true"]:not([data-focused="true"]):not([data-focus-visible="true"]) { @apply bg-field-hover; --input-bg: var(--input-bg-hover); border-color: var(--field-border-hover); } } /* Focus state */ &:focus, &[data-focused="true"] { @apply status-focused-field; border-color: var(--field-border-focus); --input-bg: var(--input-bg-focus); background-color: var(--input-bg); } /* Invalid state */ &[data-invalid="true"] { @apply status-invalid-field; --input-bg: var(--input-bg-focus); background-color: var(--input-bg); } /* Disabled state */ &:disabled, &[data-disabled="true"], &[aria-disabled="true"] { @apply status-disabled; } /** * Browser autofill (`:-webkit-autofill` in Chromium, `:autofill` in Firefox). * The user agent paints its own background over the author background, which * drops `.input--secondary`'s fill and reads as the primary field. Cover that * paint with `--input-bg` (the variant's current fill) and keep the field * foreground. Border stays on the rules above — autofill is not focus. * The long background-color transition stops Chromium's highlight from fading in. * box-shadow is not transitioned: the 1000px inset must appear at once, or the * highlight shows while that cover grows in from 0. */ &:-webkit-autofill, &:-webkit-autofill:hover, &:-webkit-autofill:focus, &:-webkit-autofill:active, &:autofill, &:autofill:hover, &:autofill:focus, &:autofill:active { background-color: var(--input-bg); box-shadow: var(--input-autofill-shadow); -webkit-box-shadow: var(--input-autofill-shadow); -webkit-text-fill-color: var(--field-foreground); caret-color: var(--field-foreground); transition: background-color 9999s ease-in-out 0s, border-color 150ms var(--ease-smooth); @media (prefers-reduced-motion: reduce) { transition: background-color 9999s ease-in-out 0s; } } } /* Variant property definitions */ .input--primary { /* Default styles */ } .input--secondary { @apply shadow-none; background-color: var(--input-bg); --input-bg: var(--default); --input-bg-hover: var(--default-hover); --input-bg-focus: var(--default); @media (hover: hover) { &:hover:not(:focus):not(:focus-visible), &[data-hovered="true"]:not([data-focus-visible="true"]):not([data-focused="true"]) { --input-bg: var(--input-bg-hover); background-color: var(--input-bg); } } &:focus, &[data-focused="true"] { --input-bg: var(--input-bg-focus); background-color: var(--input-bg); } /* Invalid state */ &[data-invalid="true"] { @apply status-invalid-field; --input-bg: var(--input-bg-focus); background-color: var(--input-bg); } } /* Full width modifier */ .input--full-width { @apply w-full; }