[Tips] Organizing your Tailwind ClassName

2023. 1. 16. 04:24·Development Study/Frontend
728x90

This is a good plugin to organize your long-dizzy tailwind classnames.

You have to install Prettier before you get started

 

preview a result

<!-- Before -->
<button class="text-white px-4 sm:px-8 py-2 sm:py-3 bg-sky-700 hover:bg-sky-800">...</button>

<!-- After -->
<button class="bg-sky-700 px-4 py-2 text-white hover:bg-sky-800 sm:px-8 sm:py-3">...</button>

How to install

1. put this text in the terminal

npm install -D prettier prettier-plugin-tailwindcss

2. Save the codes by using Prettier

 

3. Well done! Happy Hacking!


+ How classes are sorted?

They sorted High Level class to Low Level class

 

examples

<!-- `container` is a component so it comes first -->
<div class="container mx-auto px-6">
<div class="pt-2 p-4">
<!-- ⬆️Before After⬇️ -->
<div class="p-4 pt-2">
<div class="text-gray-700 shadow-md p-3 border-gray-300 ml-4 h-24 flex border-2">
<!-- ⬆️Before After⬇️ -->
<div class="ml-4 flex h-24 border-2 border-gray-300 p-3 text-gray-700 shadow-md">
<div class="hover:opacity-75 opacity-50 hover:scale-150 scale-125">
<!-- ⬆️Before After⬇️ -->
<div class="scale-125 opacity-50 hover:scale-150 hover:opacity-75">
<div class="lg:grid-cols-4 grid sm:grid-cols-3 grid-cols-2">
<!-- ⬆️Before After⬇️ -->
<div class="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4">
<div class="p-3 shadow-xl select2-dropdown">
<!-- ⬆️Before After⬇️ -->
<div class="select2-dropdown p-3 shadow-xl">

End

 

 

References

더보기

https://tailwindcss.com/docs/reusing-styles

 

Reusing Styles - Tailwind CSS

Managing duplication and creating reusable abstractions.

tailwindcss.com

728x90
저작자표시 비영리 변경금지 (새창열림)

'Development Study > Frontend' 카테고리의 다른 글

[Techeer Talk] JavaScript ES6에는 어떤 변화가 있었을까?  (0) 2023.04.16
[React] 초보 개발자들이 실수하기 쉬운 것들  (0) 2023.01.17
[Quick Tips] Create New React Project  (0) 2023.01.16
[TypeScript] TypeScript Grammar - 09  (0) 2023.01.08
[TypeScript] TypeScript Grammar - 08  (0) 2023.01.08
'Development Study/Frontend' 카테고리의 다른 글
  • [Techeer Talk] JavaScript ES6에는 어떤 변화가 있었을까?
  • [React] 초보 개발자들이 실수하기 쉬운 것들
  • [Quick Tips] Create New React Project
  • [TypeScript] TypeScript Grammar - 09
ThreeLight
ThreeLight
ThreeLight Studio의 블로그, TimeMap.exe에 오신 것을 환영합니다.
  • ThreeLight
    TimeMap.exe
    ThreeLight
  • 전체
    오늘
    어제
    • 분류 전체보기 (245)
      • Checkpoint (1)
      • (3D)Dev Deep Dive (0)
        • Templates & Guides (9)
        • Frontend origin (9)
        • Backend origin (1)
        • TroubleShootings (4)
      • Development Study (95)
        • Frontend (36)
        • Backend (21)
        • CS(Computer Science) (2)
        • Background Knowledges (11)
        • Algorithm (2)
        • Mobile (3)
        • AWS (6)
        • Python (6)
        • MSW(MapleStoryWorlds) (8)
      • Coding Test (59)
        • 문제.zip (1)
        • BaekJoon_JavaScript (0)
        • Programmers_JavaScript (9)
        • BaekJoon_Python (23)
        • Programmers_Python (10)
        • Undefined_Python (3)
        • Programmers_SQL (13)
      • 활동내역.zip (43)
        • 개인 (21)
        • Techeer (12)
        • Bootcamp (7)
        • Hackathon (1)
        • TeamProjects (2)
      • 여기 괜찮네??(사이트 | App) (5)
      • 재미있는 주제들 (8)
      • 개발 외 공부 저장소 (11)
        • 생산운영관리 (3)
        • 생활속의금융 (6)
        • 경영정보시스템 (2)
  • 링크

    • TimeMap.dmg (Portfolio)
    • GitHub 바로가기
    • 오픈프로필(카카오톡)
    • Medium 바로가기
    • Disquiet 바로가기
    • LinkedIn 바로가기
  • 인기 글

  • 태그

    Baek Joon
    프로그래머스
    JavaScript
    CSS
    react
    programmers
    SQL
    TypeScript
    HTML
    Python
  • 최근 글

  • 최근 댓글

  • hELLO· Designed By정상우.v4.10.1
ThreeLight
[Tips] Organizing your Tailwind ClassName
상단으로

티스토리툴바