Перейти до основного вмісту
← 🎨 CSS as a design system·Модуль B9 · Урок 2
ЗавданняBuild .button with custom-prop API: --bg, --fg, --pad-x, --pad-y, --font-size, --radius. Default values are primary + medium. Variants override the props: .button.danger sets --bg to --danger. .button.success sets --bg to --success. .button.secondary sets --bg to --surface, --fg to --text, adds border. .button.sm sets --pad-x to var(--space-sm) and --pad-y to 6px. .button.lg sets --pad-x to var(--space-lg) and --pad-y to var(--space-md). All have transition + hover (lift -1px) + active (back down) + focus-visible (outline 2px primary).

Capstone 2: компонент кнопки з 6 варіантами

200 XP14 min
Теорія

The .button component as the canonical example

3 sizes (sm, md, lg) × 4 colors (primary, secondary, danger, success) = 12 visual variants. We build it via custom-property props so the CSS stays minimal.

Plus four interaction states (rest, hover, active, focus-visible) handled correctly per WCAG.

🔒

Зареєструйся щоб кодувати

Теорія відкрита всім. Інтерактивний редактор, живий перегляд і перевірка відкриваються з 7-денним безкоштовним trial — потрібна картка, скасування у будь-який час.

Реєстрація — безкоштовний trial →

Перші 10 уроків у кожному треку — безкоштовні. Картка не потрібна.

← НазадНаступний урок →

Отримуй одну пораду з Python чи вебу — щодня поштою

Коротко, без води, без спаму. Відписка — в один клік.