๐๐ป ์นํ์ด์ง๋ฅผ ํ๋ฉด์ ํํํ๊ธฐ ์ํด์ HTML์ ์ฌ์ฉํฉ๋๋ค.
HTML is used to display web pages on the screen.
๐๐ป ์ด ์นํ์ด์ง๋ฅผ ์คํ์ผ๋ง ํ๊ธฐ์ํด์๋ ๊ธฐ๋ณธ์ ์ผ๋ก css๋ฅผ ์ฌ์ฉํฉ๋๋ค.
CSS is primarily used to style this webpage.
๐๐ป ์นํ์ด์ง ์คํ์ผ๋ง์ ํ๊ธฐ ์ํด ์ฌ์ฉํ๋ ๊ธฐ๋ณธ css์ฝ๋๊ฐ ๋๋ฌด ๊ธธ๊ธฐ ๋๋ฌธ์ tailwindcss๋ฅผ ์ฌ์ฉํ๋ฉด ๊ฐ์ ๊ธฐ๋ฅ์ ๊ตฌํํ๊ธฐ ์ํ ์ฝ๋๊ฐ ๋ ์งง์์ง๋๋ค.
Standard CSS code for styling web pages can be quite lengthy, whereas using Tailwind CSS allows you to implement the same functionality with less code.
๐๐ป tailwind๋ ์คํ์๋๊ฐ ๋น ๋ฅด๊ณ ๋คํฌ๋ชจ๋๋ฑ์ ๊ธฐ๋ฅ์ ๊ตฌํํ๊ธฐ๊ฐ ํจ์ฌ ์ฉ์ดํฉ๋๋ค.
Tailwind offers fast execution speeds and makes it much easier to implement features like dark mode.
๐๐ป ์ด ํ๋ก์ ํธ์์๋ ํ
์คํธ์ ๊ฐ๋จํ ๋ฒํผ์ css์ tailwindcss๋ก ๊ตฌํํฉ๋๋ค.
In this project, text and simple buttons are implemented using CSS and Tailwind CSS.
๐๐ป Nextjsํ๋ก์ ํธ ์์ฑ์ ์ด ํฌ์คํธ์ ๊ฐ์ฅ ์๋ ๋ถ๋ถ์ ์ฐธ์กฐํ์ธ์
Please refer to the bottom of this post for instructions on creating a Next.js project.
๐๐ป ์ ์ฒด ์ฝ๋๋ ๊นํ๋ธ์์ ํ์ธ ํ ์ ์์ต๋๋ค.
You can find the full code on GitHub.
https://github.com/gideonslife01/flm-webui
๐ ํ ์คํธ / Text
โ๏ธ tailwincss์ฌ์ฉํ๋ ค๋ฉด ๊ธฐ๋ณธ ์นํ์ด์ง์ ์์ HTML ํ๊ทธ์ tailwindcss๋ฅผ ๋ค์์ฒ๋ผ ์ ์ฉํฉ๋๋ค.
To use Tailwind CSS, apply it to the HTML tags within your web page as follows.
<p className="mt-4 text-sm text-gray-400">Next.js + Tailwind CSS</p>
1) mt-4 :
— ๊ณต์๋ฌธ์/Official Documentation
https://tailwindcss.com/docs/margin#adding-margin-to-a-single-side
A. ์ปดํฌ๋ํธ ์์ชฝ์ 4๋งํผ์ ์ฌ๋ฐฑ์ ํ๋ณดํฉ๋๋ค.
Leave a margin of 4 above the component.
B. mt์์ ์ซ์๋ ์๋์ ํ๋ฅผ ์ฐธ์กฐํ์ธ์
Please refer to the table below for the numbers next to ‘mt’.
| ํด๋์ค / Class | rem | px |
|---|---|---|
mt-1 | 0.25rem | 4px |
mt-2 | 0.5rem | 8px |
mt-3 | 0.75rem | 12px |
mt-4 | 1rem | 16px |
mt-6 | 1.5rem | 24px |
mt-8 | 2rem | 32px |
2) text-sm :
— ๊ด๋ จ ๋ฌธ์ / Official Documents
https://tailwindcss.com/docs/font-size#basic-example
A.๊ธ์ํฌ๊ธฐ๋ฅผ 14px๋ก ์ค์ ํฉ๋๋ค.
B.text์์ ๋ฌธ์๋ ์๋์ ํ๋ฅผ ์ฐธ์กฐํ์ธ์
Please refer to the table below for the characters next to the text.
| ํด๋์ค/Class | rem | px | line-height |
|---|---|---|---|
text-xs | 0.75rem | 12px | 16px |
text-sm | 0.875rem | 14px | 20px |
text-base | 1rem | 16px | 24px – ๊ธฐ๋ณธ๊ฐ/default value |
text-lg | 1.125rem | 18px | 28px |
text-xl | 1.25rem | 20px | 28px |
3)text-gray-400 :
— ๊ด๋ จ๋ฌธ์ / Official Documents
https://tailwindcss.com/docs/colors#using-color-utilities
A.๊ธ์ ์์ ํ์์ผ๋ก ์ค์ ํ๊ณ ์งํ๊ธฐ๋ 400์ผ๋ก ์ค์ ํฉ๋๋ค.
Set the text color to gray and the weight to 400.
B.์ซ์์ ๋ถ๋ถ์ ์๋์ ์ค๋ช
์ ์ฐธ์กฐํ์ธ์
Please refer to the explanation below regarding the numbers.
text-gray-50
- ์์ฃผ ์ฐํ ํ์ / Very light gray
text-gray-200
- ์ฐํ ํ์ / Light gray
text-gray-400
- ์ฝ๊ฐ ์ฐํ ํ์ / A slightly light gray - #9ca3af
text-gray-600
- ์งํ ํ์ / Dark gray
text-gray-900
- ์์ฃผ ์งํ ํ์ / Very dark gray
โ๏ธ ๊ธฐ๋ณธ CSS์์๋ ์์ ์ฝ๋๋ฅผ ๊ตฌํํ๋ฉด ์๋์ ๊ฐ์ต๋๋ค.
Implementing the code above using standard CSS results in the following:
<p className="helper">Next.js + Pure CSS</p>
<style>{` ...
.helper {
margin-top: 16px;
font-size: 14px;
color: #9ca3af;
}
`}</style>
๐ก ๊ณต์๋ฌธ์๋ tailwind.com์ ๊ฒ์์ ํ์ฉํ์๋ฉด ๋ฉ๋๋ค.
You can find official documents by using the search function on tailwind.com.
๐ ๋ฒํผ / Button
โ๏ธ tailwindcss๋ฅผ ๋ฒํผ์ ์ ์ฉํ๊ธฐ ์ํ ์ฝ๋๋ ์๋์ ๊ฐ์ต๋๋ค.
The code for applying Tailwind CSS to a button is as follows.
โ๏ธ ๋ฒํผ ํ
์คํธ๋ “tailwind ์์ํ๊ธฐ/Start”๊ฐ ํ๋ฉด์ ํ์๋๊ณ ๋ฒํผ ํด๋ฆญ์ “ํด๋ฆญ๋จ/Clicked”๊ฐ ํ์๋ฉ๋๋ค.
The button displays “tailwind ์์ํ๊ธฐ/Start,” and changes to “ํด๋ฆญ๋จ/Clicked” when clicked.
<button
onClick={handleClick}
className="px-6 py-3 bg-blue-500 text-white rounded-xl font-bold shadow-md hover:bg-blue-600 hover:-translate-y-0.5 active:scale-95 transition-all"
>
{clicked ? 'ํด๋ฆญ๋จ/Clicked ๐' : 'tailwind ์์ํ๊ธฐ/Start'}
</button>
1) ์์ ์ฝ๋์ ๋ํ ์ค๋ช
์ ์๋์ ๊ฐ์ต๋๋ค.
An explanation of the code above is provided below.
1. ํฌ๊ธฐ (์ฌ๋ฐฑ) / Size (Margins)
px-6
- ์ข์ฐ ์์ชฝ ์ฌ๋ฐฑ 24px (6 * 4px)
Left and right inner margins: 24px (6 ร 4px)
py-3
- ์์๋ ์์ชฝ ์ฌ๋ฐฑ 12px (3 * 4px)
Top and bottom inner margins: 12px (3 ร 4px)
2. ์ / Color
bg-blue-500
- ๋ฐฐ๊ฒฝ์ ํ๋์ ์งํ๊ธฐ ์ค๊ฐ ์ ๋ (#3b82f6)
Background color: blue, medium intensity.
text-white
- ๊ธ์์ ํฐ์
Text color: white
3. ๋ชจ์ / shape
rounded-xl
- ๋ชจ์๋ฆฌ ๋ฅ๊ธ๊ฒ 12px
Rounded corners 12px
font-bold
- ๊ธ์ ๋๊ป 700 (๊ตต๊ฒ)
Font weight 700 (Bold)
shadow-md
- ๊ทธ๋ฆผ์ ์ค๊ฐ ํฌ๊ธฐ
Medium-sized shadow
4. ์ํธ์์ฉ / Interaction
hover:bg-blue-600
- ๋ง์ฐ์ค ์ฌ๋ฆฌ๋ฉด ๋ฐฐ๊ฒฝ์ ๋ ์งํ ํ๋์ผ๋ก
Change the background color to a darker blue on hover.
hover:-translate-y-0.5
- ๋ง์ฐ์ค ์ฌ๋ฆฌ๋ฉด 2px ์๋ก ์ด์ง ๋ธ (-0.5 = -2px)
Hovers up by 2px (-0.5 = -2px)
active:scale-95
- ํด๋ฆญํ๋ ์๊ฐ 95% ํฌ๊ธฐ๋ก ์ด์ง ์์์ง
It shrinks slightly to 95% of its size the moment you click it.
transition-all
- ์ ๋ณํ๋ค์ ๋ถ๋๋ฝ๊ฒ ์ ๋๋ฉ์ด์
์ผ๋ก
Smoothly animate the above changes
โ๏ธ ๊ธฐ๋ณธ CSS์์๋ ์์ ๋ฒํผ ์ฝ๋๋ฅผ ๊ตฌํํ๋ฉด ์๋์ ๊ฐ์ต๋๋ค.
Implementing the button code above with basic CSS results in the following.
... ...
<button
onClick={handleClick}
className="btn-primary"
>
{clicked ? 'ํด๋ฆญ๋จ/Clicked ๐' : 'CSS ์์ํ๊ธฐ/Start'}
</button>
... ...
<style>{`
/* ๋ฒํผ ๊ธฐ๋ณธ / Button Basic */
.btn-primary {
padding: 12px 24px;
background-color: #3b82f6;
color: white;
border-radius: 12px;
font-weight: 700;
font-size: 16px;
border: none;
cursor: pointer;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
transition: all 0.2s ease;
}
/* ๋ฒํผ ๋ง์ฐ์ค ์ค๋ฒ / Button mouseover */
.btn-primary:hover {
background-color: #2563eb;
transform: translateY(-2px);
box-shadow: 0 6px 10px rgba(0,0,0,0.15);
}
/* ๋ฒํผ ํด๋ฆญ / Button active */
.btn-primary:active {
transform: scale(0.95);
}
/* ๋ฒํผ ํ๋จ ํ
์คํธ / Text below the button */
.helper {
margin-top: 16px;
font-size: 14px;
color: #9ca3af;
}
`}</style>
... ...
โ๏ธ ๋๋จธ์ง๋ ์ปจํ
์ด๋ ์
๋๋ค.
The rest are containers.
— tailwind
<main className="min-h-screen flex flex-col items-center justify-center bg-gray-50"> ... ... </main>
1)tailwind์ฝ๋ ์ค๋ช
์
๋๋ค.
Here is an explanation of the Tailwind code.
1. min-h-screen
- ํ๋ฉด ๋์ด๋งํผ ์ต์ ๋์ด๋ฅผ ํ๋ณด, ๋ด์ฉ์ด ์ ์ด๋ ํ๋ฉด ๊ฝ ์ฐจ๊ฒ.
Ensure a minimum height equal to the screen height so that the content fills the screen, even if there is little content.
2. flex
- ํ๋ ์ค ๋ชจ๋ ์ผ๊ธฐ
Turn on Flex mode
display: flex
- ์์ ์์๋ค์ ์ ์ฐํ๊ฒ ๋ฐฐ์นํ๋ ๋ชจ๋. ์ด๊ฑธ ์ผ์ผ ์๋ ์ ๋ ฌ ๋ช
๋ น๋ค ์ฌ์ฉ๊ฐ๋ฅ ํจ.
A mode for flexibly arranging child elements. You must enable this to use the alignment commands below.
3. flex-col
- ์์ ์ปดํฌ๋ํธ๋ค์ ๋ฐฉํฅ
Orientation of child components
- flex-direction: column
- ์์๋ค์ ์ธ๋ก๋ก ์๊ธฐ (๋ฒํผ ์์ ํ
์คํธ ์๋ ๊ฐ์ํ์) ์ ์ฐ๋ฉด ๊ธฐ๋ณธ์ ๊ฐ๋ก(row).
If you don't specify otherwise, the default layout for children is horizontal (row); stacking them vertically (e.g., text below a button) requires a different setting.
4. items-center
- ๊ฐ๋ก(์ข์ฐ) ์ค์ ์ ๋ ฌ
Horizontal (left-right) center alignment
- align-items: center
- ์ธ๋ก๋ก ์์์ ๋๋ ์ข์ฐ๋ฅผ ๊ฐ์ด๋ฐ๋ก ์ ๋ ฌ
When stacked vertically, center the left and right sides.
- flex-col์ผ ๋ ์ข์ฐ ์ค์ ์ ๋ ฌ ๋ด๋น
Handles horizontal centering when using flex-col.
5. justify-center
- ์ธ๋ก(์์๋) ์ค์ ์ ๋ ฌ
Vertical (top-to-bottom) center alignment
- justify-content: center
- ์ธ๋ก๋ก ์์์ ๋๋ ์์๋๋ฅผ ๊ฐ์ด๋ฐ๋ก ์ ๋ ฌ
When stacked vertically, center the top and bottom.
- items-center + justify-center ๊ฐ์ด ์ฐ๋ฉด ์ ๊ฐ์ด๋ฐ ์ ๋ ฌ
Use `items-center` and `justify-center` together to center-align perfectly.
6. bg-gray-50
- ๋ฐฐ๊ฒฝ์
background color
- background-color: #f9fafb
- ์์ฃผ ์ฐํ ํ์.
A very pale gray.
— css
<main className="wrapper"> ... ... </main>
<style>{`
/* ์ปจํ
์ด๋ / Container */
.wrapper {
width: 100%;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background-color: #f9fafb;
}
`}</style>
๐ Nextjs ํ๋ก์ ํธ ์์ฑ / Create a Next.js project
โ๏ธ nextjsํ๋ก์ ํธ๋ฅผ ํฐ๋ฏธ๋์์ ์์ฑํฉ๋๋ค.
npx create-next-app@latest
โ๏ธ ์๋์ฒ๋ผ ๊ธฐ๋ณธ๊ฐ์ผ๋ก Nextjs๋ฅผ ๊ธฐ๋ณธ๊ฐ์ผ๋ก ์ค์นํ๋ฉด tailwindcss๊ฐ ์๋์ผ๋ก ์ค์น๋ฉ๋๋ค.
WebUI % npx create-next-app@latest
โ What is your project named? โฆ tailwindcss-nextjs
โ Would you like to use the recommended Next.js defaults? โบ Yes, use recommended defaults
Creating a new Next.js app in /Users/... .../tailwindcss-nextjs.
Using npm.
Initializing project with template: app-tw
Installing dependencies:
- next
- react
- react-dom
Installing devDependencies:
- @tailwindcss/postcss
- @types/node
- @types/react
- @types/react-dom
- eslint
- eslint-config-next
- tailwindcss
- typescript
๐ ํ ์คํธ / Test
โ๏ธ tailwind button

โ๏ธ css button

CSS
์ํ๋ณต์ 8์ฅ 32์ / John 8:32
“๊ทธ๋ฆฌ๊ณ ๋ํฌ๋ ์ง๋ฆฌ๋ฅผ ์๊ฒ ๋ ๊ฒ์ด๋ฉฐ, ์ง๋ฆฌ๊ฐ ๋ํฌ๋ฅผ ์์ ๋กญ๊ฒ ํ ๊ฒ์ด๋ค.”
“Then you will know the truth ,and the truth will set you free”