BiTree
  • Search For Lessons
  • Curriculum
  • Pricing
  • For Educators
  • Become a Tutor
  • About
  • Contact
Log InGet Started

Questions, concerns, bug reports, or suggestions? We read every message, write to us at [email protected].

More ways to reach us →
BiTree

Live coding lessons for aspiring developers and security professionals.

[email protected]

(201) 785-7951

Mon–Fri, 9 AM–5 PM EST

Learn

  • Search For Lessons
  • Curriculum
  • Pricing

Company

  • About
  • For Educators & Schools
  • Become a Tutor
  • Contact Us

Legal

  • Terms of Service
  • Privacy Policy
© 2026 BiTree. All rights reserved.
Curriculum/Web Development/Component-Driven Design Thinking
35 minBeginner

Component-Driven Design Thinking

After this lesson, you will be able to: Look at any UI and decompose it into reusable components at the right granularity, decide whether a piece of UI should be a component or a styled element, and name components in a way that a teammate could find them.

Component-driven design is the architectural shift that took the React era from "a way to render HTML" to "a way to design entire products." Treating UI as composable pieces is what makes design systems possible, what makes Figma-to-code handoff sane, and what makes a junior developer's code reviewable. This lesson takes you from "what's a component?" to confidently breaking down a marketing page into the five or six components it actually is.

Prerequisites:Tailwind CSS: The Utility-First Mental Model

Why components exist

Three reasons a senior engineer treats UI as components and a beginner doesn't yet. **Reuse** — a button on the homepage and a button in the dashboard are the same button. If you make them as one `<Button>` component, fixing the focus ring fixes it everywhere. If you copy-paste markup, you fix it in one place and forget the other three. **Consistency** — designers ship a design system with named components (Button, Card, NavItem). When engineers' code structure mirrors that, the implementation matches the design without ad-hoc invention. **Reviewability** — a 30-line `<UserProfileCard>` is much easier to review than a 200-line `<div>` soup. Components draw boundaries that PRs respect.

Atomic design, briefly

Brad Frost's atomic design hierarchy is the most common mental model. It has five levels — you don't have to fully adopt it, but knowing the vocabulary helps you read other people's design systems. **Atoms** are the smallest pieces: a label, a single input, an icon. **Molecules** are atoms grouped into a unit: a labeled input field, a search bar (input + button). **Organisms** are bigger compositions: a header, a product card. **Templates** are page-layout skeletons with placeholder content. **Pages** are templates filled with real data. Most production codebases use the middle three — atoms, molecules, organisms — and skip the page/template distinction because routes naturally play that role.

How to look at a UI and decompose it

A three-step process that works on any screenshot or Figma file. (1) **Squint at it.** Identify the biggest visual blocks first — header, content, footer; nav, sidebar, main. These are your top-level layout components. (2) **Find the repeats.** Anything that appears more than once with the same shape is a component candidate. Three pricing cards, six nav links, a list of users — each repeated element is a component. (3) **Notice the same-shape-different-content patterns.** A blog post card and a project card might be the same `<Card>` with different inner content. A 'Save' button and a 'Delete' button might be the same `<Button>` with different variants.

A component decomposition example

A pricing page in plain HTML on the left; the same page mentally decomposed into components on the right. Notice how repetition collapses: three pricing cards become one `<PricingCard>` rendered three times with different props.

html
<!-- Raw HTML view -->
<header>
<a>Logo</a>
<nav><a>Plans</a><a>FAQ</a></nav>
</header>
<section>
<h1>Pick a plan</h1>
<div class="grid grid-cols-3 gap-4">
<div class="card">
<h2>Hobby</h2>
<p>$0/mo</p>
<button>Sign up</button>
</div>
<div class="card">
<h2>Pro</h2>
<p>$12/mo</p>
<button>Sign up</button>
</div>
<div class="card">
<h2>Team</h2>
<p>$48/mo</p>
<button>Contact us</button>
</div>
</div>
</section>
<!-- Same page, as components -->
<Header>
<Logo />
<Nav links={[{...}, {...}]} />
</Header>
<PricingSection title="Pick a plan">
<PricingCard name="Hobby" price="$0" ctaLabel="Sign up" />
<PricingCard name="Pro" price="$12" ctaLabel="Sign up" />
<PricingCard name="Team" price="$48" ctaLabel="Contact us" />
</PricingSection>
<!-- Components in play: Header, Logo, Nav, PricingSection, PricingCard -->
<!-- Five reusable components instead of one giant page. -->

Props vs many variants

A common trap: making three components (`<PrimaryButton>`, `<SecondaryButton>`, `<DangerButton>`) when one `<Button variant="primary" | "secondary" | "danger">` does the same job. Components share more than they differ — express the differences as props. The opposite trap: cramming every variation into one component until its props list is 30 items long. When that happens, the component is probably trying to be two things — split it. Rule of thumb: if 80% of the code is the same between two variants, use props. If only 30% overlaps, they're separate components.

Component vs styled element

Not every styled `<div>` should be a component. Components have a real cost — they live in a separate file, they create indirection, they need names. The right boundary: a component when the same shape appears at least three times, OR when the encapsulation buys you something (focus management, accessibility wiring, prop-driven variants). A one-off styled div in a single page is fine as inline markup. Don't pre-extract. Wait for the third repeat, then extract.

💡 Storybook exists (mention only)

Once you have a real component library, you'll want a place to view and document each component in isolation. **Storybook** is the standard tool for that — it gives every component its own page with controllable props. You don't need it on day one, but you'll see it in every job posting at companies that take their design system seriously. Worth knowing the name.

Exercise: decompose a real marketing page

Open `bitree.dev` in a browser tab (or another marketing site you like — Stripe.com is a great example). Take a screenshot of the homepage. Then, in writing or on paper, identify five components: their names, what props each takes, and how many times each appears on the page.

  1. 1

    Open the homepage of a marketing site in your browser

  2. 2

    Scroll through the whole page and take note of every UI block

  3. 3

    Name at least five reusable components you'd extract

  4. 4

    For each component, list 1-3 props it would need to support the variants you see

  5. 5

    Count how many times each component appears on the page

  6. 6

    Bonus: for one component, sketch the markup with Tailwind utilities and prop placeholders ({title}, {price}, etc.)

Quick Check

Which is the strongest signal that something should be a component?

Multiple options are reasonable. Pick the strongest.

💡 Common mistakes only experienced devs catch

Five component-design pitfalls. (1) Premature extraction — making `<UserGreeting>` because you might reuse it later. You usually don't. Wait for three repeats. (2) Over-narrow naming — `<HomePageHero>` can't be used anywhere else. `<Hero>` with props can. (3) Too-many-variants components — when a `<Button>` has 12 boolean props it's two or three components in a trench coat. Split them. (4) Bypassing the component for one-off styling — `<Button className="!bg-red-500">` defeats the whole point. If a variant doesn't exist, add it as a prop. (5) Mixing layout components with content components — a `<Page>` that hard-codes a marketing hero inside its layout is doing two jobs. Layout is layout; content is content; keep them in separate components.

Reading a Figma file as a developer

Most teams hand off designs in Figma, and reading one is a core developer skill. Open the file and use Dev Mode (or the Inspect panel): click any element to see its exact CSS values (color, font size, line height, padding, border radius), select two elements to measure the spacing between them, and copy the generated CSS or Tailwind values. Map what you see to components first (find the repeated pieces), then to design tokens (the named colors and spacing), then build. You do not pixel-push by eye; you read the values the designer already set and translate them into your component structure.

Sign in and purchase access to unlock this lesson.

Sign in to purchase
←Responsive Design with Tailwind Breakpoints
Back to Web Development
JavaScript Fundamentals→