๐ Tailwind css๋?
HTML ์์์, CSS ์คํ์ผ์ ๋ง๋ค ์ ์๊ฒ ํด์ฃผ๋ CSS ํ๋ ์์ํฌ
ํ์์ฑ
์ด๋ค ๋ถ๋ถ์, ์ด๋ค ์คํ์ผ์ ์ ์ฉํ๋์ง ํ๋์ ๋ณผ ์ ์๊ฒ ํด์ค๋ค!
PostCSS ํ๋ฌ๊ทธ์ธ์ผ๋ก ์ค์น
npm install -D tailwindcss postcss autoprefixer
# postcss์ tailwindcss, autoprefixer ํ๋ฌ๊ทธ์ธ์ ์ค์น
PostCSS๋?
[CSS/Node.js] PostCSS๋? ์ฌ์ฉ๋ฒ, ํ๋ฌ๊ทธ์ธ ์ถ์ฒ
PostCSS๋? CSS ํ์ฒ๋ฆฌ๊ธฐ์ด๋ฉฐ, CSS ์์ฑ์ ๋ ํธํ๊ฒ ๋ง๋ค์ด์ฃผ๋ javascript ๋๊ตฌ๋ค(Plugins)์ด๋ค. javascript๋ฅผ ์ด์ฉํด์, CSS๋ฅผ ๋ณ๊ฒฝํ๋ค. ํ์ฒ๋ฆฌ๊ธฐ๋? [CSS] CSS ์ ,ํ ์ฒ๋ฆฌ๊ธฐ๋? / ๋น๊ต CSS ์ ,ํ ์ฒ๋ฆฌ๊ธฐ๋? C..
defineall.tistory.com
PostCSS ์ค์
//postcss.config.js
module.exports = {
plugins: {
'postcss-import': {},
tailwindcss: {},
autoprefixer: {},
}
}
Tailwind css ์ด๊ธฐ ์ค์
npx tailwindcss init
์ค์ ํ์ผ ์์
// tailwind.config.js
module.exports = {
content: [
"./src/**/*.{js,ts,jsx,tsx}", // ์ ์ฉํ jsํ์ผ ๊ฒฝ๋ก ์ง์
],
theme: {
extend: {},
},
plugins: [],
}
CSS์ Tailwind ๋ฃ๊ธฐ
/* styles.css */
@import "tailwindcss/base";
@import "tailwindcss/components";
@import "tailwindcss/utilities";
Tailwind ์ปค์คํฐ ๋ง์ด์งํ๊ธฐ
// tailwind.config.js
// ์ปฌ๋ฌ๋ฅผ ์ปค์คํฐ๋ง์ด์งํ๊ธฐ ์ํ tailwindcss/colors ๋ชจ๋ ๋ถ๋ฌ์ค๊ธฐ
const colors = require('tailwindcss/colors')
module.exports = {
darkMode: false, // or 'media' or 'class'
theme: {
// extend์ ๊ฒน์น๋ ์ค์ ์ด ์์ ๊ฒฝ์ฐ ๊ธฐ๋ณธ css ์คํ์ผ์ ์ฐ์ ์ํ๋ค.
extend: {
// ๋ด๊ฐ ์ํ๋ ์ปฌ๋ฌ๋ฅผ ๊ธฐ๋ณธ ์ปฌ๋ฌ๋ก ์ง์ ํด์ ์ฌ์ฉํ ์ ์๋ค.
color: {
gray: colors.coolGray,
blue: colors.lightBlue,
red: colors.rose,
pink: colors.fuchsia,
},
// ๋ด๊ฐ ์ํ๋ ํฐํธ๋ฅผ ๊ธฐ๋ณธ ํฐํธ๋ก ์ง์ ํ ์ ์๋ค.
fontFamily: {
sans: ["Grapik", "sans-serif"],
serif: ["Merriweather", "serif"],
}
}
},
...
}
Tailwind ์ฌ์ฉ๋ฒ
<button class="py-2 px-4 font-semibold rounded-lg shadow-md text-white bg-green-500 hover:bg-green-700">
Hello, Tailwind CSS!
</button>

| ์์น ์ ๋ ฅ | |
| ml | margin-left; |
| mx | margin-left margin-right; |
| my | margin-top margin-bottom; |
| pl | padding-left; |
| px | padding-left padding-right; |
| py | padding-top padding-bottom; |
| w | witdh; |
| max-w | max-width; |
| h | height; |
| max-h | max-height; |
| ml-2 ํ์์ผ๋ก ์ฌ์ฉํ๋ค / margin-left : 2px; | |
| auto | auto; |
| full | 100%; |
| screen | 100vh or 100vw; |
| Display | |
| block | display: block; |
| inline-block | display:inline-block; |
| inline | display: inline; |
| flex | display: flex |
| inline-flex | display: inline-flex; |
| table | display: table; |
| table-row | display: table-row; |
| table-cell | display: table-cell; |
| hidden | display: none; |
| Position | |
| static | position: static; |
| fixed | position: fixed; |
| absolute | position: absolute; |
| relative | position: relative; |
| sticky | position: sticky; |
| Top / Right / Bottom / Left | |
| inset-0 | top: 0; right: 0; bottom: 0; left: 0; |
| inset-x-0 | right: 0; left: 0; |
| inset-y-0 | top: 0; bottom: 0; |
| top-0 | top: 0; |
| right-0 | right: 0; |
| bottom-0 | bottom: 0; |
| left-0 | left: 0; |
| Text Transform | |
| uppercase | text-transform: uppercase; |
| lowercase | test-transform: lowercase; |
| capitalize | test-transform: capitalize; |
| normal-case | test-transform: none; |
| z-index | |
| z-0 | z-index: 0; |
| z-10 | z-index: 10; |
| z-auto | z-index: auto; |
| Font-size | |
| text-xs | font-size: .75rem; |
| text-sm | font-size: .875rem; |
| text-base | font-size: 1rem; |
| text-lg | font-size: 1.125rem; |
| text-2xl | font-size: 1.5rem; |
| text-3cl | font-size: 1.875rem; |
| Line-height | |
| leading-none | line-height: 1; |
| leading-tight | line-height: 1.25; |
| leading-snug | line-height: 1.375; |
| leading-normal | line-height: 1.5; |
| leading-relaxed | line-height: 1.625; |
| leading-loose | line-height: 2; |
| Font-weight | |
| font-hairline | font-weight: 100; |
| font-thin | font-weight: 200; |
| font-light | font-weight: 300; |
| font-normal | font-weight: 400; |
| font-medium | font-weight: 500; |
| font-semibold | font-weight: 600; |
| font-bold | font-weight: 700; |
| font-extrabold | font-weight: 800; |
| font-black | font-weight: 900; |
| Background-color | |
| bg-transparent | background-color: transparent; |
| bg-black | background-color: #000; |
| bg-white | background-color: #fff; |
| be-gray-100 | background-color: #f7fafc; |
| Border style | |
| border-solid | border-style: solid; |
| border-dashed | border-style: dashed; |
| border-dotted | border-style: dotted; |
| border-double | border-style: double; |
| border-none | border-style: none; |
| Border color | |
| border-transparent | border-color: transparent; |
| border-black | border-color: #000; |
| border-white | border-color: #fff; |
| border-gray-100 | border-color: #f7fafc; |
| Border size | |
| border | border-width: 1px; |
| border-0 | border-width: 0; |
| border-2 | border-width: 2px; |
| border-4 | border-width: 4px; |
| border-t | border-top-width: 1px; |
| border-r | border-right-width: 1px; |
| border-b | border-bottom-width: 1px; |
| border-l | border-left-width: 1px; |
| Border radius | |
| rounded-none | border-radius: 0; |
| rounded-sm | border-radius: .125rem; |
| rounded | border-radius: .25rem; |
| rounded-lg | border-radius: .5rem; |
| rounded-full | border-radius: .9999px; |
| rounded-tl-none | border-top-left-radius: 0; |
| rounded-tr-none | border-top-right-radius: 0; |
| rounded-bl-none | border-bottom-left-radius: 0; |
| rounded-br-none | border-bottom-right-radius: 0; |
| rounded-tl-full | border-top-left-radius: 9999px; |
| rounded-tr-full | border-top-right-radius: 9999px; |
| rounded-bl-full | border-bottom-left-radius: 9999px; |
| rounded-br-full | border-bottom-right-radius: 9999px; |
| Width / Height ( w๋ฅผ h๋ก ๋ณ๊ฒฝํ๋ฉด height ) | |
| w-0 | width: 0; |
| w-1 | width: 0.25rem; |
| ... | ... |
| w-auto | width: auto; |
| w-px | width: 1px; |
| w-1/2 | width: 50%; |
| w-1/3 | width: 33.333333%; |
| ... | ... |
| w-10/12 | width: 83.333333%; |
| w-11/12 | width: 91.666667%; |
| w-full | width: 100%; |
| w-screen | width: 100vw; |
| Padding / Margin ( p๋ฅผ m์ผ๋ก ๋ณ๊ฒฝํ๋ฉด Margin ) | |
| ์ ์ฒด ์กฐ์ | |
| p-0 | padding: 0; |
| p-1 | padding: 0.25rem; |
| ๊ฐ์ ์กฐ์ | |
| px-0 | padding-left: 0; padding-right: 0; |
| px-1 | padding-left: 0.25rem; padding-right: 0.25rem; |
| py-0 | padding-top: 0; padding-bottom: 0; |
| py-1 | padding-top: 0.25rem; padding-bottom: 0.25rem; |
| pt-0 | padding-top: 0; |
| pt-1 | padding-top: 0.25rem; |
| pb-0 | padding-bottom: 0; |
| pb-1 | padding-bottom: 0.25rem; |
| pl-0 | padding-left: 0; |
| pl-1 | padding-left: 0.25rem; |
| pr-0 | padding-right: 0; |
| pr-1 | padding-right: 0.25rem; |
| ํฝ์ ์กฐ์ | |
| p-px | padding: 1px; |
| px-px | padding-right: 1px; padding-left: 1px; |
| py-px | padding-top: 1px; padding-bottom: 1px; |
| pt-px | padding-top: 1px; |
| pb-px | padding-bottom: 1px; |
| pl-px | padding-left: 1px; |
| pr-px | padding-right: 1px; |
| Cursor | |
| cursor-auto | cursor: auto; |
| cursor-default | cursor: default; |
| cursor-pointer | cursor: pointer; |
| cursor-wait | cursor: wait; |
| cursor-text | cursor: text; |
| cursor-move | cursor: move; |
| cursor-not-allowed | cursor: not-allowed; |
| Opacity | |
| opacity-100 | opacity: 1; |
| opacity-75 | opacity: .75; |
| opacity-50 | opacity: .5; |
| opacity-25 | opacity: .25; |
| opacity-0 | opacity: 0; |
๋ฐ์ํ