(์ถ๊ฐ ์์ )
content
: tailwindCSS๋ฅผ ์ ์ฉํ ๊ฒฝ๋ก๋ค์ ๋น ๋ฐฐ์ด์ ์
๋ ฅํ๋ค.
์ด๋ ํ๋ก์ ํธ์์ src
๋๋ ํ ๋ฆฌ๋ฅผ ์ฌ์ฉํ๋ค๋ฉด src๋ก ์์ํ๋ ๊ฒฝ๋ก 1๊ฐ๋ง ์
๋ ฅํ๋ฉด ๋๋ค.
// tailwind.config.js
module.exports = {
content: [
"./app/**/*.{js,ts,jsx,tsx,mdx}",
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
"./components/**/*.{js,ts,jsx,tsx,mdx}",
// `src` directory๋ฅผ ์ฌ์ฉํ๋ค๋ฉด
"./src/**/*.{js,ts,jsx,tsx,mdx}",
],
theme: {
extend: {},
},
plugins: [],
}
โ๏ธ๋ด๊ฐ ํ์ํ ํน์ ๊ฐ์ Tailwind์์ ์ ๊ณตํ์ง ์๋ ๊ฒฝ์ฐ ๋๊ดํธ[]๋ฅผ ์ฌ์ฉํ๋ค. ํ์ง๋ง ํน์ ๊ฐ์ด ์ฌ๋ฌ ๋ฒ ๋ฐ๋ณต๋๋ค๋ฉด ๋ฒ๊ฑฐ๋กญ๋ค.
๐๐ปโโ๏ธ tailwind.config.js
ํ์ผ์์ theme
์ extend
, color
, fontFamily
์ ์์ฃผ ์ฐ๋ ์์ฑ๊ณผ ๊ฐ๋ค์ ์ถ๊ฐํด์ค๋ค.
import type { Config } from 'tailwindcss'
import defaultTheme from 'tailwindcss/defaultTheme'
const config: Config = {
content: [
'./src/pages/**/*.{js,ts,jsx,tsx,mdx}',
'./src/components/**/*.{js,ts,jsx,tsx,mdx}',
'./src/app/**/*.{js,ts,jsx,tsx,mdx}',
],
theme: {
extend: {
fontFamily: {
sans: ['var(--font-pretendard)', ...defaultTheme.fontFamily.sans],
},
container: {
center: true,
padding: '24px',
screens: {
'2xl': '1328px',
},
},
colors: {
gray05: '#F8F9FA',
gray10: '#F1F3F5',
gray20: '#E9ECEF',
content: '#F8F9FA',
primary: '#0E1932',
placeholder: '#ADB5BD',
ring: '#0E1932',
success: '#408249',
error: '#FF5855',
},
flexBasis: {
label: '150px',
},
minWidth: {
label: '150px',
orderStatusBox: '358px', // ์ฃผ๋ฌธ/๋ฐฐ์ก/๋ฐํ ๊ด๋ฆฌ์ ์ฃผ๋ฌธ ์ฒ๋ฆฌํํฉ Box
refundStatusBox: '281.6px', //์ฃผ๋ฌธ/๋ฐฐ์ก/๋ฐํ ๊ด๋ฆฌ์ ๋ฐํ ์ฒ๋ฆฌํํฉ Box
},
backgroundImage: {
home: "url('/img/home-background.png')",
},
},
},
plugins: [require('@tailwindcss/forms')],
}
export default config
๋ค์๊ณผ ๊ฐ์ด ์ฌ์ฉ ๊ฐ๋ฅํ๋ค.
<!-- ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง๊ฐ ์ค์ ๋ ์์ญ : backgroundImage์ home ์ฌ์ฉ -->
<div class="bg-home h-64 flex items-center justify-center">
<h1 class="text-white text-3xl">ํ์ํฉ๋๋ค!</h1>
</div>
<!-- Flexbox ๋ ์ด์์ : flexBasis์ label ์ฌ์ฉ -->
<div class="flex p-4">
<div class="flex-basis-label bg-gray30 p-4">
๋ ์ด๋ธ 1
</div>
<div class="flex-1 bg-gray10 p-4">
๋ด์ฉ 1
</div>
<div class="flex-basis-label bg-gray30 p-4">
๋ ์ด๋ธ 2
</div>
<div class="flex-1 bg-gray10 p-4">
๋ด์ฉ 2
</div>
</div>
<!-- ์ต์ ๋๋น๊ฐ ์ค์ ๋ ๋ฐ์ค : minWidth์ label ์ฌ์ฉ-->
<div class="min-w-label bg-gray20 p-4">
์ฃผ๋ฌธ ์ํ: ๋ฐฐ์ก ์ค
</div>
ํ์ผ์ ๋งจ ์์ ํด๋น ์ฝ๋๋ฅผ ์ถ๊ฐํ์ฌ CSS์ Tailwind ๋๋ ํฐ๋ธ๋ฅผ ์ถ๊ฐํ๋ค.
/* global.css */
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer
: Tailwind CSS์ ์คํ์ผ์ ์ฌ๋ฌ ๋ ์ด์ด๋ก ๋๋์ด ์ ์ํ ์ ์๊ฒ ํด์ฃผ๋ ์ง์์ด. tailwind Base, components, utilities ๋ ์ด์ด์ ์คํ์ผ์ ์ถ๊ฐํ๋ค.
@apply
: Tailwind CSS์ ์ ํธ๋ฆฌํฐ ํด๋์ค๋ฅผ CSS ๊ท์น ๋ด์์ ์ฌ์ฉํ ์ ์๊ฒ ํด์ฃผ๋ ์ง์์ด
base
layer : HTML ์์์ ๋ํ ๊ธฐ๋ณธ ์คํ์ผ์ ์ค์ ํ์ฌ ์ผ๊ด๋ ์ด๊ธฐ๊ฐ ์ ๊ณตํ๋ ๋ ์ด์ดcomponents
layer : ์ฌ์ฌ์ฉ ๊ฐ๋ฅํ UI ๊ตฌ์ฑ ์์์ ์คํ์ผ์ ์ ์ํ๋ ๋ ์ด์ด ex) ๋ฒํผ, ์นด๋, ๋ชจ๋ฌ, ๋ค๋น๊ฒ์ด์
๋ฐutilities
layer : ๊ฐ๋ณ CSS ์์ฑ์ ํด๋์ค ํํ๋ก ์ ๊ณตํ๋ ๋ ์ด์ด ex) text-shadow, bg-gradient์ฐ๋ฆฌ ํ๋ก์ ํธ์์๋ components
์์ ๋ ์ด์์ ์คํ์ผ์ ์ ์ํ๊ณ , utilities
์์ ์ฌ์ฌ์ฉ ๊ฐ๋ฅํ ์ปดํฌ๋ํธ ์คํ์ผ์ ์ ์ฉํ ๊ฒ ๊ฐ๋ค.
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base {
body {
@apply bg-content;
}
button,
a {
@apply outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2;
}
}
@layer components {
.page-container {
@apply flex w-full flex-col gap-8 bg-gray10 p-8;
}
.contents-container {
@apply mt-6 flex w-full flex-col gap-6 overflow-x-auto rounded-md bg-white p-4 shadow-sm;
}
.side {
@apply flex w-1/2 flex-col gap-6 p-6;
}
}
@layer utilities {
/* Hide scrollbar for Chrome, Safari and Opera */
.no-scrollbar::-webkit-scrollbar {
display: none;
}
/* Hide scrollbar for IE, Edge and Firefox */
.no-scrollbar {
-ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none; /* Firefox */
}
.homeBg {
@apply bg-cover bg-center bg-no-repeat;
}
.eco-select {
@apply cursor-pointer appearance-none checked:bg-green70 checked:text-green70 checked:ring-transparent;
}
.delivery-price {
@apply flex h-[43px] min-w-[127px] grow items-center rounded-sm border border-gray50 bg-white;
}
.general-button {
@apply rounded border border-gray70 px-4 py-2;
}
.second-button {
...
}
.primary-button {
...
}
.green-button {
...
}
.product-detail-input {
@apply grow rounded border border-gray50 placeholder:text-gray50;
}
.contents-bg {
@apply flex rounded-lg bg-gray10;
}
.orderStatusCard {
@apply flex min-h-[164px] flex-col gap-4 rounded-lg bg-gray10 px-6 py-12;
}
}