A Short Guide to Component Naming

by Angela Fisher, Front-end Developer

1. Brevity is Key

Time is scarce, don’t waste it typing out long, descriptive component names. One approach is to give them short, cryptic names that only you will understand.

Need a button? Call it "btn". A modal? How about "md"? You’ll save precious minutes per day and you’ll get the added benefit of being the only person in the codebase who knows where anything is. This is called job security.

2. Rank High in Search

When working in large repos with lots of collaborators, it’s important that your component ranks high when people search for anything.

One way to stand out is to include all the possible search terms in your component name. Instead of “SignInButton” you might want call it “SignInButtonAuthenticationCookieUserLogIn” which will ensure that it is returned in almost any related search result.

3. Mix Languages

If you work remotely, it’s likely you are on a global team and yet all your components have English names. This slows down your non-english colleagues considerably so you should allow them to use their native tongue when naming components.

You can create an index file that maps all the different languages within your repo. Need a dropdown? Look for “Desplegable”. A form? Search “Форма”. You’ll learn multiple new languages while being more inclusive to your colleagues.

More articles

The Future of Web Development: Our Predictions for 2023

Let’s explore the latest trends in web development, and regurgitate some predictions we read on X for how they will shape the industry in the coming year.

Read more

3 Lessons We Learned Going Back to the Office

Earlier this year we made the bold decision to make everyone come back to the office full-time after two years working from a dressing table in the corner of their bedroom.

Read more

Tell us about your project

Our offices

  • Wilmington
    24A Trolley Square #1611
    Wilmington, DE 19806-3334, USA
  • Dhaka
    44/1 Rahim Square, New Market
    Dhaka 1205, Bangladesh

We value your privacy. We use cookies to enhance your browsing experience, serve personalized ads or content, and analyze our traffic. By clicking "Allow Cookies", you consent to our use of cookies. See our cookie policy.