@vivekcsein-logo
  • Home
  • About
  • Development

    • Web Development
    • Performance & Optimization
    • Backend & APIs
    • Authentication & Security

    Specialized

    • SEO & Ad Monetization
    • AR Experiences
    • Animation
    • Figma to Code
  • Articles
  • Projects
  • Marketplace
  • Contact
@vivekcsein-logo

A portfolio full stack developer with a passion for building scalable and high-performance web applications.

Explore

  • Home
  • About

Services

  • Web Development
  • Backend & APIs
  • Performance Optimization
  • Security & Authentication

Connect

  • Contact
  • Privacy
  • Terms
  • Home
  • About
  • Web Development
  • Backend & APIs
  • Performance Optimization
  • Security & Authentication
  • Contact
  • Privacy
  • Terms

© @vivekcsein. All rights reserved.

  • Home
  • All Articles47
  • Featured
  • Recently Added
  • Most Read
  • Bookmarks
Topics
  • Interview3
  • 3d4
  • Ai Prompts2
  • Business3
  • Deployment1
  • Dev2
  • Frontend5
  • Getting Started2
  • Security2
  • Seo2
  • Workflow10
    • Stage 1 — Project Initialization
    • Stage 2 — Professional Development Environment
    • Stage 3 — Enterprise Architecture
    • Stage 4 — Design System
    • Stage 5 — Design System Implementation
    • Stage 6 — Reusable UI Components
    • Stage 7 — Server-Only Icon System
    • Stage 8 — Project Environment Setup
    • Stage 9 — shadcn/ui Integration
    • Stage 10 — API Layer
  • Backend1
  • Deployment1
  • Security1
  • Javascript1
  • Client Advisory5
  • Engineering2
Collections
  • Docs
  • Tutorials
  • Resources
  • Articles
“A better developer every single day.”
— Vivek
  1. Docs
  2. Workflow
  3. Stage 6 — Reusable UI Components
Workflow

Stage 6 — Reusable UI Components

The rulebook for reusing, extending or creating UI components: Button, InputFactory, Link, IconSVG, LucideIcon and shadcn, with a decision tree.

Updated Oct 2, 20264 min read
On this page

On this page

  • Overview
  • Priority Order
  • Structure Note (resolved)
  • Component Systems
  • Button System
  • Input System
  • Link System
  • Custom SVG System
  • Lucide Icon System
  • shadcn/ui
  • Styling Responsibility
  • Decision Tree
  • Core Principle

Overview#

This is a rulebook, not a build sequence. It governs how anyone — human or AI agent — decides between reusing, extending, or creating a UI component once the library exists. Read it after Stage 7 — Server-Only Icon System and Stage 9 — shadcn/ui Integration, since it assumes LucideIcon and components/ui/shadcn already exist.

These components are core infrastructure, shared across every feature. Do not recreate them.

Priority Order#

text
Use the existing component
        ↓
Extend it — props, variants, composition
        ↓
Create a new component — last resort

A new component is justified only when no existing component, and no reasonable extension of one, satisfies the requirement.

Structure Note (resolved)#

This stage's paths use plural UI subfolders (buttons/, inputs/) plus links/ and svg//images/. Stage 3 — Enterprise Architecture has been updated to match — components/ui now lists buttons, inputs, links, svg, images, and shadcn consistently across both docs. The paths below are canonical.

Component Systems#

SystemLocationImport as
Buttonui/buttons/Button.tsx<Button />
Inputui/inputs/InputFactory.tsx<InputFactory />
Linkui/links/Link.tsx<Link />
Custom SVGui/svg/IconSVG.tsx<IconSVG />
Lucide iconsui/images/LucideIcon.tsx<LucideIcon iconName="..." />
shadcn/uiui/shadcn/per-component — see Stage 8

Button System#

Location: ui/buttons/Button.tsx — the single source of truth for buttons project-wide.

  • Always render <Button />. Never a raw <button />, unless the request is explicit about needing one.
  • New visual treatment → add a variant or size to Button, don't create a second button component.
tsx
<Button variant="primary" />
<Button variant="secondary" />
<Button variant="ghost" />
<Button variant="outline" />

Input System#

Location: ui/inputs/InputFactory.tsx — a factory that selects the correct input implementation internally via a switch-case.

  • Never build an individual input component directly.
  • Always render <InputFactory /> and let it resolve the type.

Supported types: text, email, password, number, textarea, select, checkbox, radio, switch, date, search.

  • New input type needed → extend InputFactory with the new case and keep the API shape consistent. Don't ship a standalone input component alongside it.

Link System#

Location: ui/links/Link.tsx — unified internal/external navigation with the project's default styling and behavior built in.

  • Always render <Link />.
  • Don't reach for a raw <a /> or the framework's link primitive directly unless specifically required — styling belongs inside Link, not repeated at every call site.

Custom SVG System#

Location: ui/svg/IconSVG.tsx — renders the project's custom, non-Lucide SVG assets.

  • Always render <IconSVG />. Never inline raw <svg> markup into a page or feature component.
  • New brand/custom asset → add it to the SVG system, not embedded ad hoc.

Lucide Icon System#

Location: ui/images/LucideIcon.tsx — see Stage 7 — Server-Only Icon System for the full implementation and the reasoning behind it.

  • Always render <LucideIcon iconName="Home" /> for icons known at build time — nearly every icon in the app.
  • Never import { Home } from "lucide-react" directly in a feature component; that bypasses the registry and reintroduces per-component tree-shaking guesswork.
  • New icon needed → add it to the registry in LucideIcon.tsx (one import, one map entry), then use it by name.
  • Icon name only known at runtime (CMS, database) → this is the one case LucideIcon doesn't cover. Use the documented DynamicIcon escape hatch from Stage 7 instead of extending the registry as a workaround.

shadcn/ui#

Location: ui/shadcn/ — everything generated by the shadcn CLI. See Stage 9 — shadcn/ui Integration for the generation workflow.

  • Don't hand-write a component that duplicates one already in ui/shadcn/.
  • Component missing → install it with the CLI (bunx --bun shadcn@latest add <name>) and let it land in ui/shadcn/ — don't hand-roll it as a stopgap.
  • Don't manually recreate what the CLI generates — regenerate or update instead.

Styling Responsibility#

Global styles (Stage 4/5) own design tokens, typography, spacing, color, motion, and accessibility baselines. Component appearance lives inside the reusable components themselves — Button.tsx, InputFactory.tsx, Link.tsx, IconSVG.tsx, LucideIcon.tsx — not in the pages that use them.

Pages and feature components are responsible for layout, composition, and business logic only. They should never redefine how a shared component looks.

Decision Tree#

text
Need a button?              → ui/buttons/Button.tsx
Need an input?               → ui/inputs/Input.tsx
Need an input for Form?      → ui/inputs/InputFactory.tsx
Need a link?                  → ui/links/Link.tsx
Need a custom SVG?             → ui/svg/IconSVG.tsx
Need a Lucide icon?             → ui/images/LucideIcon.tsx
Need a shadcn component?         → check ui/shadcn/ first, install via CLI if missing
Need something none of these cover?
                                    → create a new component, last resort

Core Principle#

These components are the project's design system, not a suggestion. Extending an existing component costs a variant; duplicating one costs consistency, maintainability, and a second implementation to keep in sync forever. Default to reuse.

PreviousStage 5 — Design System ImplementationNext Stage 7 — Server-Only Icon System

Keep reading

  • Workflow

    Stage 4 — Design System

    The design-system contract: semantic tokens, light/dark/system themes, shadcn-compatible variables and how every token maps to a Tailwind utility.

    3 min read·Oct 2, 2026
  • Workflow

    Stage 9 — shadcn/ui Integration

    Integrate shadcn/ui into the project's architecture: components.json aliases, theme presets via ui.shadcn.com or tweakcn, safe diffs and generated-component rules.

    10 min read·Oct 2, 2026
  • Workflow

    Stage 5 — Design System Implementation

    Implement the design system: CSS variables, next-themes, typography, spacing, radius and shadow scales, cn(), CVA variants and the first reusable UI components.

    3 min read·Oct 2, 2026

On this page

  • Overview
  • Priority Order
  • Structure Note (resolved)
  • Component Systems
  • Button System
  • Input System
  • Link System
  • Custom SVG System
  • Lucide Icon System
  • shadcn/ui
  • Styling Responsibility
  • Decision Tree
  • Core Principle