npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -ptailwind.config.js 파일 생성
module.exports = { content: [ "./pages/**/*.{js,jsx,tsx,ts}", "./components/**/*.{js,jsx,ts,tsx}", ],
📌
pages
디렉토리에 있는모든 폴더
에 있는모든 파일
에 적용하겠다 는 의미.
💡 ex) *.{tsx} : tsx 확장자 파일에만 tailwind css를 적용하겠음!
<div className="bg-slate-400 py-10">
py 와 숫자 의미
.py-10 { padding-top: 2.5rem/* 40px */; padding-bottom: 2.5rem/* 40px */; }
💡 px는 left, right!!
모든 자식 요소에 margin-top, margin-bottom 생성
return (
<div className="bg-slate-400 py-10 px-5 flex flex-col space-y-5">
<div className="bg-white p-10 rounded-2xl"></div>
<div className="bg-white p-10 rounded-2xl"></div>
<div className="bg-white p-10 rounded-2xl"></div>
<div className="bg-white p-10 rounded-2xl"></div>
</div>
<div className="bg-slate-400 py-10 px-5 grid gap-10">
== display: grid
grid와 gap 속성으로 위와 똑같은 화면 구성이 가능하다.
<button className="w-5 h-5 rounded-full bg-yellow-500 focus:ring-2 ring-offset-2 ring-yellow-500"></button>
ring-{width}
ring offset과 color는 변수인 것을 확인할 수 있다. 따라서 focus를 ring-{width} 앞에만 붙여줘도 전부 적용된 것과 같이 동작한다.