Frontend School
DashboardProblemsLearnPracticeMock InterviewReportsStatsBuy Credits
DashboardProblemsLearnPracticeMock Interview
Frontend System Design Fundamentals
  1. 1.Introduction to Frontend System Design
  2. 2.Core Frontend Architecture Concepts
  3. 3.Client-Server Interaction Fundamentals
  4. 4.Basic Performance & Accessibility Considerations
  5. 5.State Management Basics & Data Flow
  6. 6.Advanced State Management & Global Stores
  7. 7.Component Libraries & Design Systems
  8. 8.Frontend Build Tools & Development Workflows
  9. 9.Advanced Performance Optimization Techniques
  10. 10.Data Fetching Strategies & Caching
  11. 11.Frontend Security Essentials
  12. 12.Micro-Frontend Architectures
  13. 13.Real-time Communication & WebSockets
  14. 14.Observability, Monitoring, & Logging
  15. 15.Offline-First & Progressive Web Apps (PWAs)
Frontend System Design Fundamentals
07

Frontend System Design · Lesson 7 of 15 · 5 min

Component Libraries & Design Systems

This topic signals you can think about frontend architecture at scale, beyond a single feature or app.

When an interviewer asks you to "design a reusable component," they are testing more than your React skills. They are probing your understanding of consistency, scalability, and collaboration. Your answer should demonstrate that you see components not as isolated pieces of code, but as parts of a larger, coherent system.

Distinguish a Component Library from a Design System

This is a frequent screening question. A fuzzy answer suggests a lack of experience with large-scale frontend development. Be precise.

A Component Library is a distributable package of reusable UI components. Think of it as the coded implementation: the React Button, the Vue Modal, the Angular DatePicker. Its primary consumers are developers.

A Design System is the entire ecosystem. It includes the component library but also establishes the rules, principles, and tooling that govern the user experience. It's the single source of truth for both designers and developers.

A design system contains:

  • Design Tokens: The primitive values—color, spacing, typography—that underpin all styling. They are abstract (--color-brand-primary) rather than literal (#5A33C8).
  • Component Library: The coded UI building blocks.
  • Style and Content Guides: Rules for voice, tone, and visual language.
  • Tooling & Documentation: Figma libraries for designers, Storybook for developers.

The component library is a product of the design system.

The trap: Don't just list the parts. Explain the relationship. Say, "A component library is the set of coded components, while the design system is the overarching framework that defines how and why those components look and behave the way they do, using tools like design tokens and documented principles."

How to Architect a Reusable Component

When asked to design a component, immediately start with its API (its props) and how it's styled. This shows you prioritize the developer experience and maintainability. The key is to separate logic, structure, and styling.

Design tokens are the foundation. Instead of hardcoding #007bff or 16px, you use variables that represent design decisions. This allows for global changes and theming.

Here is a Button component built with this principle in mind, using styled-components to consume tokens. This pattern is common and demonstrates a solid understanding of modern CSS architecture.

// --- Design Tokens (e.g., design-tokens.ts) ---
export const colors = {
  primary: '#007bff',
  secondary: '#6c757d',
  textLight: '#ffffff',
};

export const spacing = {
  xs: '4px',
  sm: '8px',
  md: '16px',
};

export const typography = {
  fontSize: {
    md: '16px',
  },
};

// --- Button Component (e.g., components/Button.tsx) ---
import React from 'react';
import styled from 'styled-components';
import { colors, spacing, typography } from '../design-tokens';

type ButtonVariant = 'primary' | 'secondary';

interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
  variant?: ButtonVariant;
  isLoading?: boolean;
}

const StyledButton = styled.button<{ $variant: ButtonVariant }>`
  padding: ${spacing.sm} ${spacing.md};
  font-size: ${typography.fontSize.md};
  border-radius: ${spacing.xs};
  cursor: pointer;
  border: 1px solid transparent;
  transition: opacity 0.2s ease-in-out;

  /* Apply styles based on the variant prop */
  ${({ $variant }) => `
    background-color: ${colors[$variant]};
    border-color: ${colors[$variant]};
    color: ${colors.textLight};
  `}

  &:disabled {
    opacity: 0.7;
    cursor: not-allowed;
  }
`;

const Button: React.FC<ButtonProps> = ({
  variant = 'primary',
  isLoading = false,
  children,
  ...rest
}) => {
  return (
    <StyledButton
      $variant={variant}
      disabled={isLoading || rest.disabled}
      {...rest}
    >
      {isLoading ? 'Loading...' : children}
    </StyledButton>
  );
};

export default Button;

This approach centralizes design decisions in the token files. If the brand's primary color changes, you update one value, and every primary button across the application updates automatically. This is the core value proposition.

Justify Building vs. Buying a System

An interviewer might ask, "Your team needs a component library. Should you build one or use something like Material UI?" This question tests your business sense and ability to weigh trade-offs.

There is no single right answer. Your response should be a structured analysis.

Use an off-the-shelf library (e.g., Material UI, Ant Design) when:

  • Speed is critical. You need to ship a product fast and don't have time for design system development.
  • The product doesn't require a unique brand identity. The standard look-and-feel is acceptable.
  • The team is small. You lack the dedicated resources (designers, developers) to maintain a custom system.

Build a custom system when:

  • Brand identity is a key differentiator. The product requires a unique, bespoke user experience that can't be achieved by tweaking a third-party library.
  • You operate at scale. Multiple products or teams need to share a consistent UI, and a custom system provides the necessary control and governance.
  • You have specific, complex component needs that off-the-shelf solutions don't cover well.

A strong answer sounds like this: "My decision depends on the project's goals and constraints. For a new startup trying to find product-market fit, I'd strongly recommend a library like Chakra UI to move quickly. For an established company with multiple product lines, the long-term cost of not having a custom design system—inconsistent UX and duplicated effort—is far greater than the initial investment to build one."

What Signals Seniority Beyond the Code

Your ability to discuss the non-code aspects of a design system is what separates a senior from a mid-level candidate. These are the operational challenges of making a system successful.

Governance: How does a new component get added? A good process involves collaboration between design, engineering, and product. It usually looks like this:

  1. Proposal: A team identifies a need for a new pattern.
  2. Design: A system designer creates specs in Figma, ensuring it fits the existing language.
  3. Review: Stakeholders approve the design.
  4. Implementation: An engineer builds the component, including tests, documentation, and accessibility features.
  5. Release: The component is versioned (using Semantic Versioning) and published.

Adoption: A design system is useless if no one uses it. You need to evangelize it. Talk about:

  • Documentation: Using tools like Storybook to provide live examples, prop documentation, and usage guidelines.
  • Onboarding: Training new hires on how to use the system.
  • Support: Providing a clear channel (e.g., a Slack channel) for users to ask questions and report bugs.

Accessibility (a11y): This is non-negotiable. Senior candidates bake accessibility in from the start. Mention specific practices: ensuring keyboard navigability, managing focus, using correct ARIA attributes, and checking for sufficient color contrast. Building these into the core components saves hundreds of hours down the line.

Try it

Take a component you've recently built (or find one in an open-source project) that has hardcoded style values like padding: '10px' or color: '#333'. Refactor it to use design tokens. Define a simple tokens object for colors and spacing, and update the component's styling to reference those tokens. This should take about 15 minutes.

Next: We'll cover Frontend Build Tools & Development Workflows, the systems that compile, bundle, and deploy the components you design.

Lock it in — apply this lesson under interview conditions.

Try a free mock interviewPractice system design problems
Previous

Advanced State Management & Global Stores

Next

Frontend Build Tools & Development Workflows