Using responsive utility variants to build adaptive user interfaces.
Tailwind의 모든 utility class는 서로 다른 breakpoint에 따라 조건부로 적용될 수 있으며, 이를 이용하여 매우 쉽게 HTML만을 사용하여 복잡한 반응형 디자인 인터페이스를 개발할 수 있다.
일반적인 기기 해상도를 고려하여 5개의 default breakpoints들이 있다.
| Breakpoint prefix | Minimum width | CSS |
|---|---|---|
sm |
640px | @media (min-width: 640px) { ... } |
md |
768px | @media (min-width: 768px) { ... } |
lg |
1024px | @media (min-width: 1024px) { ... } |
xl |
1280px | @media (min-width: 1280px) { ... } |
2xl |
1536px | @media (min-width: 1536px) { ... } |
일종의 modifier라고 생각하고, 콜론(:)을 통해 prefix로 붙여서 사용하면 된다.


이런식의 반응형 요소를 구현하려면 아래처럼 작성하면 된다.
<div class="max-w-md mx-auto bg-white rounded-xl shadow-md overflow-hidden md:max-w-2xl">
<div class="md:flex">
<div class="md:shrink-0">
<img class="h-48 w-full object-cover md:h-full md:w-48" src="/img/building.jpg" alt="Modern building architecture">
</div>
<div class="p-8">
<div class="uppercase tracking-wide text-sm text-indigo-500 font-semibold">Company retreats</div>
<a href="#" class="block mt-1 text-lg leading-tight font-medium text-black hover:underline">Incredible accommodation for your team</a>
<p class="mt-2 text-slate-500">Looking to take your team away on a retreat to enjoy awesome food and take in some sunshine? We have a list of places to do just that.</p>
</div>
</div>
</div>
md 하나로, md prefix를 통해 해당 화면 크기 이상일때 조건부로 (큰화면용) 스타일을 추가로 적용하고 있는 모습이다.잘못된 예
<!-- This will only center text on screens 640px and wider, not on small screens -->
<div class="sm:text-center"></div>
올바른 예
<!-- This will center text on mobile, and left align it on screens 640px and wider -->
<div class="text-center sm:text-left"></div>