Home
Bookmarks
Leagues
LEARN
Courses
Career Paths
Assessments
Tutorials
Arcade
Glossary
GROW
Certifications
Log in
Glossary
Log inSign up
Courses/Introduction to Design Systems/Atomic Design & Modular Component Architecture/
Exercise #6

Principles of Clean Component API Design

A component's API (its props, events, and slots) is an interface contract with other engineers. Poor API design causes bugs, frustration, and abandonment.

Rules for World-Class Component APIs:

  1. Predictable Prop Naming: Align with HTML standards. Use disabled (not isDisabled), onClick (not handleClick or performAction), and children for content.
  2. Use Enums / Union Types for Variants: Instead of multiple conflicting booleans (isPrimary, isSecondary, isDanger), use a single variant union: variant?: 'primary' | 'secondary' | 'danger'.
  3. Sensible Defaults: Every optional prop should have a smart default so <Button>Click me</Button> renders beautifully without configuring 10 props.
  4. Pass-Through Native Attributes: Always spread native props (e.g., ...rest onto the underlying <button> or <input>) so consumers can attach aria-* tags or test IDs.

Topics

Brad Frost's Atomic Design Methodology
Atoms: The Indivisible Building Blocks
Molecules: Composition & Single Responsibility
Organisms: Distinct Functional Sections
Component Composition vs 'Prop Explosion'
Principles of Clean Component API Design
Handling the 4 Essential Component States
Templates & Pages: Testing Stress & Edge Cases
Headless UI Primitives & Unstyled Foundations
Challenge: Deconstructing a Flight Booking Card

From lesson

1

Atomic Design & Modular Component Architecture

Level 4 · Component Architecture & Visual Language

Top contributors

Community contribution details will appear here once real learner activity is available.

Share