Sari la conținutul principal
← 🎨 CSS as a design system·Modul B9 · Lecția 4
SarcinăBuild form field components. Each .field is a wrapper with display: flex, flex-direction: column, gap: 4px. .field label has font-size 14px, font-weight 500. .field input has padding 8px 12px, border 1px solid var(--border), border-radius var(--radius-md), font 1rem. .field input:focus has outline 2px solid var(--primary), outline-offset -1px. .field input:user-invalid has border-color var(--danger). .field .error has color var(--danger), font-size 13px, display: none. .field:has(input:user-invalid) .error has display: block. Demo: a form with 3 fields (email, password, age) + their errors.

Capstone 4: componenta formular (intrare + etichetă + eroare)

200 XP14 min
Teorie

A form group with proper validation states

Each form group is: label + input + (optional) help text or error.

States:

  • Rest — neutral border.
  • Focus — primary outline.
  • Invalid (with :user-invalid) — red border + error text appears.
  • Disabled — muted opacity.

:user-invalid is the modern :invalid — it ONLY applies AFTER the user interacts. Stops "all fields red on page load."

🔒

Înregistrează-te pentru a începe să programezi

Teoria e accesibilă tuturor. Editorul, previzualizarea live și verificarea se deblochează cu o probă gratuită de 7 zile — card necesar, anulabilă oricând.

Înregistrare — probă gratuită →

Primele 10 lecții din fiecare traseu sunt gratis. Fără card.

← AnterioarăLecția următoare →

Primește un sfat Python sau web pe zi — prin email

Scurt, scris de mână, fără spam. Dezabonare cu un click.