Tailwind 는 최근 웹 개발 분야에서 상당히 인기를 끌고 있는 차세대 CSS 프레임워크입니다. 기존에는 Bootstrap, Styled-components 을 많이 사용했는데 현재는 개발 생산성이 높은 Tailwind 가 대세로 자리잡고 있습니다.
예시 - Tailwind 적용 전 ( 공식문서 기준 )
<div class="chat-notification">
<div class="chat-notification-logo-wrapper">
<img class="chat-notification-logo" src="/img/logo.svg" alt="ChitChat Logo">
</div>
<div class="chat-notification-content">
<h4 class="chat-notification-title">ChitChat</h4>
<p class="chat-notification-message">You have a new message!</p>
</div>
</div>
<style>
.chat-notification {
display: flex;
max-width: 24rem;
margin: 0 auto;
padding: 1.5rem;
border-radius: 0.5rem;
background-color: #fff;
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
.chat-notification-logo-wrapper {
flex-shrink: 0;
}
.chat-notification-logo {
height: 3rem;
width: 3rem;
}
.chat-notification-content {
margin-left: 1.5rem;
padding-top: 0.25rem;
}
.chat-notification-title {
color: #1a202c;
font-size: 1.25rem;
line-height: 1.25;
}
.chat-notification-message {
color: #718096;
font-size: 1rem;
line-height: 1.5;
}
</style>
<div class="p-6 max-w-sm mx-auto bg-white rounded-xl shadow-lg flex items-center space-x-4">
<div class="shrink-0">
<img class="h-12 w-12" src="/img/logo.svg" alt="ChitChat Logo">
</div>
<div>
<div class="text-xl font-medium text-black">ChitChat</div>
<p class="text-slate-500">You have a new message!</p>
</div>
</div>
장점
- 클래스의 이름을 고민하지 않아도 됩니다.
- 쉽게 반응형 페이지를 구현할 수 있도록 지원합니다.
Tip
- VS Code 를 사용할 경우 Tailwind CSS IntelliSense 플러그인 추천
SSAFY 에서 1학기 관통 프로젝트로 영화 추천 페이지를 제작할 때 처음 사용했습니다. Bootstrap 을 대다수 사용하는데 색상이 마음에 들지 않아서 찾다가 카카오 FE 개발팀에서 적극적으로 도입하고 있다는 것을 알게 되어 저도 도입해봤습니다.
직접 Tailwind 를 경험해본 바로는 개발 속도가 빨라지는 장점이 크게 와닿았습니다. 스타일 시트를 오가는 컨텍스트 스위칭도 없고, 클래스 이름을 시맨틱하게 정하기 위해 고민해야 하는 시간도 사라졌습니다. 페이지를 수정할 때도 CSS가 어떻게 적용되었는지 한 눈에 파악할 수 있어 스타일 수정에 드는 시간도 단축되었습니다.
개발 생산성 측면에서 효율적이고 빠르게 디자인을 구현할 수 있도록 도와주고 스타일 수정이 쉬워서 유지 보수성 측면에서도 Tailwind 가 우수하다고 느꼈습니다. 기존의 스타일링 방식으로 다시는 돌아가지 못할 것 같다고 느꼈기에 추후에도 계속 Tailwind 를 사용할 것이고 여러분에게도 추천합니다.
npm install -D tailwindcss
npm tailwindcss init
module.exports = {
content: ["./src/**/*.{html,js}"],
theme: {
extend: {},
},
plugins: [],
};
/* app.css */
@tailwind base;
@tailwind components;
@tailwind utilities;
npm run start
/* App.js */
export default function App() {
return (
<h1 className="text-3xl font-bold underline">
Hello world!
</h1>
)
}
이런 유용한 정보를 나눠주셔서 감사합니다.