My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

Which indentation style you prefer for JSX code?

Marko Stijak's photo
Marko Stijak
·Oct 24, 2016

One liners

3%

Line per attribute, regular indent

16%

Line per attribute, aligned

8%

Multiline

74%

38 votes · Closed

There are a couple of ways to indent JSX code. Which style you find to be the best:

  1. One liners

    return <div className="well" style={{ border: "1px solid orange", padding: "2rem" }}>
     Content
    </div>
    
  2. Line per attribute, regular indent

    return <div className="well" 
     style={{ 
       border: "1px solid orange", 
       padding: "2rem" 
     }}>
     Content
    </div>
    
  3. Line per attribute, aligned

    return <div className="well" 
                style={{ 
                  border: "1px solid orange", 
                  padding: "2rem" 
                }}>
     Content
    </div>
    
  4. Multiline

    return (
     <div 
       className="well" 
       style={{
         border: "1px solid orange", 
         padding: "2rem" 
       }}
     >
       Content
     </div>
    )