odd:bg-gray-100:nth-child(odd) 에 해당even:bg-cyan-100:nth-child(even) 에 해당pt-5 first:pt-0:first-childfirst:md:pt-0)border-b-2 last:border-b-0:last-childlast:md:border-b-0)animate-bounce는 말그대로 지정한 영역이 바운스함!!!@keyframes bounce {
0%, 100% {
transform: translateY(-25%);
animation-timing-function: cubic-bezier(0.8,0,1,1);
}
50% {
transform: none;
animation-timing-function: cubic-bezier(0,0,0.2,1);
}
}
.animate-bounce {
animation: bounce 1s infinite;
}
animate-spin는 모래시계 등 로딩될때 넣어주면 계속 돌아감<div className="size-6 bg-red-500 text-white flex items-center justify-center rounded-full animate-spin">
<span>⌛️</span>
</div>
@keyframes spin {
to {
transform: rotate(360deg);
}
}
.animate-spin {
animation: spin 1s linear infinite;
}
animate-pulse는 특히 스켈레톤 만들때 유용하다.(스켈레톤이란? 뼈대를 나타내며 더미 영역이다.loading될때 영역을 잡아주는 것)
<div className="flex items-center gap-5 animate-pulse">
<div className="size-10 bg-blue-400 rounded-full" />
<div className="w-40 h-4 rounded-full bg-gray-400" />
<div className="w-20 h-4 rounded-full bg-gray-400" />
</div>
@keyframes pulse {
50% {
opacity: .5;
}
}
.animate-pulse {
animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
animate-ping을 주면 가장자리 뒷 배경이 뿌옇 느낌으로 깜빡거림의 효과를 줄 수 있다.<div className="size-6 bg-red-500 text-white flex items-center justify-center rounded-full relative">
<span className="z-10">1</span>
<div className="size-6 bg-red-500 rounded-full rounded-ful absolute animate-ping" />
</div>
@keyframes ping {
75%, 100% {
transform: scale(2);
opacity: 0;
}
}
.animate-ping {
animation: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;
}
<div className="bg-white shadow-lg p-5 rounded-3xl w-full max-w-screen-sm flex flex-col md:flex-row gap-3">
{["yeah", "Me", "You", "Yourself", ""].map((person, index) => (
<div key={index} className="flex items-center gap-5">
<div className="size-10 bg-blue-400 rounded-full" />
<span className="text-lg font-medium empty:w-24 empty:h-5 empty:rounded-full empty:bg-gray-300 empty:animate-pulse">
{person}
</span>
<div className="size-6 bg-red-500 text-white flex items-center justify-center rounded-full relative">
<span className="z-10">{index}</span>
<div className="size-6 bg-red-500 rounded-full rounded-ful absolute animate-ping" />
</div>
</div>
))}
</div>
.empty\:bg-gray-300:empty {
--tw-bg-opacity: 1;
background-color: rgb(209 213 219 / var(--tw-bg-opacity, 1)) /* #d1d5db */;
}
empty:w-24 empty:h-5 empty:rounded-full empty:bg-gray-300 empty:animate-pulse 로 클래스를 지정해준다면 스켈레톤을 만들 수 있다. <ul class="transition">
<li class="group flex cursor-pointer items-center gap-2 text-3xl transition hover:text-white">
<span class="flex size-5 items-center justify-center rounded-full bg-black text-xs font-thin uppercase text-white transition group-hover:bg-white group-hover:text-yellow-300">T</span>
<strong class="font-medium">Test</strong>
</li>
</ul>
.group:hover .group-hover\:text-yellow-300 {
--tw-text-opacity: 1;
color: rgb(253 224 71 / var(--tw-text-opacity, 1)) /* #fde047 */;
}
focus within이다. (group invalid도 유용함)<div className="group">
<input type="email"
placeholder="Write your email"
className="bg-gray-100 w-full"
/>
<span className="group-focus-within:block hidden">
Make sure it is a valid email...
</span>
<button>Submit</button>
</div>
.group:focus-within .group-focus-within\:block {
display: block;
}
css에도 있는 코드들이지만 간단하게 테일윈드로 클래스 입력만으로도 스타일이 꾸며지고 있다.
내가 css를 알고 있기 때문에 엄청 편하지는 않지만 css를 모르는 사람들은 테일윈드만 알아도 디자인을 할 수 있으니 얼마나 편리한가!
클래스명도 직관적이라 css 만들때도 참고하면 좋을거 같고, empty, :focus-within는 css에 있지만 잘 사용하지 않았던건데 덕분에 알게 되었다.
animate 부분은 정말 편한거 같다. 만들어진 코드들로 디자인을 확인해보니 디자인이 아주 세련되어서 ui적으로도 너무 좋은거 같다. 테일윈드... 회사에서 써보고 싶다.