A Short Guide to Component Naming

by Guest Contributor, Freelance Front-end Developer

1. Be Descriptive and Clear

A good component name tells you what the component does without needing to read its implementation. Future developers (including yourself) will thank you for choosing clarity over brevity.

Instead of cryptic abbreviations like "btn" or "md", use full descriptive names like "SubmitButton" or "ConfirmationModal". The few extra characters are worth the improved readability and maintainability.

Good component names should answer three questions: What does it do? What type of component is it? Where or how is it used? For example, "UserProfileCard" tells you it's a card component that displays user profile information.

2. Follow Consistent Patterns

Consistency in naming helps developers navigate your codebase efficiently. Establish patterns and stick to them across your project.

Common patterns include:

  • Prefix specialized components: "AuthButton", "PaymentForm", "DashboardLayout"
  • Use standard suffixes for component types: "List", "Item", "Container", "Wrapper"
  • Be specific about context: "CheckoutStepIndicator" vs generic "StepIndicator"

When searching for components, consistent naming means developers can make educated guesses about what names might exist. If you have "ProductCard", they'll expect "ProductList" not "ProductGrid" or "ShowProducts".

3. Balance Specificity and Reusability

Component names should be specific enough to be clear but generic enough to be reusable. This is a balance that improves with experience.

For example, "PrimaryActionButton" is better than "SubmitCheckoutButton" if the component is used across multiple contexts. But if it truly has checkout-specific logic, the more specific name is appropriate.

Consider the component's scope:

  • Highly reusable: Generic names like "Button", "Card", "Modal"
  • Domain-specific: Names like "ProductCard", "UserAvatar", "CommentThread"
  • Feature-specific: Names like "CheckoutSummary", "DashboardHeader"

The key is making sure the name accurately reflects the component's actual purpose and reusability. Don't make it more generic than it needs to be, and don't make it so specific that it can't be used where it makes sense.

More articles

The Future of Web Development: Our Predictions for 2023

Exploring the latest trends in web development and how AI, modern frameworks, and new runtime environments are reshaping how we build for the web.

Read more

3 Lessons from Building a Hybrid Work Culture

After transitioning to a hybrid work model, we learned valuable lessons about productivity, collaboration, and maintaining company culture across distributed teams.

Read more

Tell us about your project

Our offices

  • London
    86-90 Paul Street
    London, England, EC2A 4NE