Tech Interview RoomStudy guides

React Ecosystem

How do you choose a styling approach and a component library for a React app?

Advanced · 2 min read · Lesson 7 of 7 in React Ecosystem

Styling options

  • Tailwind CSS: utility classes in markup; fast iteration, consistent design tokens, tiny CSS output (unused classes removed). Long class lists are tamed with components and clsx/cva variants. Very popular with shadcn/ui.
  • CSS Modules: plain CSS scoped per file (styles.button); zero runtime, works everywhere, including Server Components.
  • Zero-runtime CSS-in-JS: vanilla-extract, Panda CSS, StyleX: typed styles extracted at build time.
  • Runtime CSS-in-JS (styled-components, Emotion): dynamic and colocated, but adds runtime cost and does not work in Server Components without client boundaries; many teams are moving away for new projects.

Component libraries

  • Full design systems: MUI (Material), Ant Design, Chakra UI, Mantine: many ready components, theming, fast to build admin apps; heavier and opinionated look.
  • Headless primitives: Radix UI, React Aria (Adobe), Headless UI, Ark UI: behaviour and accessibility (focus management, keyboard support, ARIA) without styles; you own the look.
  • shadcn/ui: you copy components (built on Radix + Tailwind) into your codebase and own the code; easy to customise, no version lock-in.

How to decide

Consider the design requirements (custom brand or standard look), accessibility needs (prefer libraries with tested keyboard and screen reader support), SSR/Server Component compatibility, bundle size, team familiarity and long-term maintenance.

Example

tsx
// A variant-based button with Tailwind + class-variance-authority (the shadcn/ui pattern)
import { cva, type VariantProps } from 'class-variance-authority';
import { clsx } from 'clsx';

const button = cva(
  'inline-flex items-center justify-center rounded-lg font-semibold transition focus-visible:outline-none focus-visible:ring-2 disabled:opacity-50',
  {
    variants: {
      variant: {
        primary: 'bg-indigo-600 text-white hover:bg-indigo-700 focus-visible:ring-indigo-400',
        ghost: 'bg-transparent text-indigo-700 hover:bg-indigo-50',
        danger: 'bg-red-600 text-white hover:bg-red-700',
      },
      size: { sm: 'h-8 px-3 text-sm', md: 'h-10 px-4', lg: 'h-12 px-6 text-lg' },
    },
    defaultVariants: { variant: 'primary', size: 'md' },
  },
);

type ButtonProps = React.ComponentProps<'button'> & VariantProps<typeof button>;

export function Button({ variant, size, className, ...props }: ButtonProps) {
  return <button className={clsx(button({ variant, size }), className)} {...props} />;
}

// <Button variant="danger" size="sm" onClick={remove}>Delete</Button>

Follow-up questions interviewers ask

Try answering each one before you open it.

Why are headless libraries popular for design systems?

Accessible interactive widgets (menus, comboboxes, dialogs, date pickers) are hard to get right. Headless libraries provide tested behaviour, keyboard navigation and ARIA wiring, while the team keeps full control of markup and styling to match the brand.