๐Ÿ“–
aug-note
  • 1๏ธโƒฃ frontend
    • HTML / CSS
      • Simentic Tag
      • Flex
      • Grid
      • class vs id
      • Attribute vs Property
      • form
      • Tailwind
        • base, utility, component, layer
        • tailwind.config
    • React
      • Next.js
        • Next.js 15
        • Tanstack Query with Next.js
      • Library
        • react-hook-form
      • React vs Next.js
      • React Hooks
      • Redux
      • Life Cycle
      • Ref
      • Suspense
      • Hydration
      • Virtual DOM
      • Component
      • library / framework
  • 2๏ธโƒฃ Flutter
    • Widget
    • pubspec.yaml
  • 3๏ธโƒฃ Language
    • JavaScript
      • TypeScript
        • Generic
        • Interface, Type Alias
        • Utility Type
        • tsconfig.json
        • Schema vs Type
        • Type Guard
        • Tuple
      • JS Variables
      • Event loop
      • Arrow function
      • Ajax
      • async await
      • blocking / non-blocking
      • sync/async
      • Closure
      • Execution Context
      • Lexical Scope
      • this
      • Truthy / Falsy
      • Event
      • package manager
        • npm
        • yarn
    • Dart
      • Variables
      • Factory
  • 4๏ธโƒฃ Computer Science
    • Network
      • OSI 7 Layer
      • TCP / IP
      • DNS
      • UDP
      • Load Balancing
      • http / https
      • CORS
    • OS
      • Computer Structure
      • Operating System
      • CPU Scheduling
      • Process
      • Memory Structure
      • Interrupt
      • Compile
    • Web
      • API
      • webpack
      • Barbel
      • DOM
      • SEO
      • Web Storage
      • Session / JWT
      • SSR / CSR
      • SSG
      • Web Socket
      • SPA
    • Data Structure
      • Linear Data Structure
      • Non-Linear Data Structure
    • Design Pattern
      • Flux
      • Observer
      • BFF
    • Software Engineering
      • TDD
      • OOP
    • Cloud Computing
      • K8S
  • 5๏ธโƒฃ BlockChain
    • BlockChain
    • Mining
    • Smart Contract
Powered by GitBook
On this page
  1. 1๏ธโƒฃ frontend
  2. HTML / CSS
  3. Tailwind

tailwind.config

tailwind๋ฅผ ์ ์šฉ์‹œ ํ•„์ˆ˜์ ์œผ๋กœ ์ƒ์„ฑ๋˜๋Š” ํŒŒ์ผ ์ค‘ ํ•˜๋‚˜๊ฐ€ ๋ฐ”๋กœ tailwind.config.ts ์ด๋‹ค. tailwind ๊ด€๋ จ ์„ค์ •์„ ํ•˜๋Š” ํŒŒ์ผ๋กœ ๋ณด์ด๋Š”๋ฐ ์–ด๋–ค ์—ญํ• ์„ ํ•˜๋Š”์ง€ ์‚ดํŽด๋ณด์ž.

์šฐ์„ , tailwind.config ํŒŒ์ผ์€ ๋นŒ๋“œํƒ€์ž„์— tailwind๊ฐ€ ๋ณ€ํ™˜ํ•  ํด๋ž˜์Šค ๋„ค์ž„์„ ํƒ์ƒ‰ํ•˜๋Š”๋ฐ, ์ด๋•Œ ํด๋ž˜์Šค ๋„ค์ž„์ด ์œ„์น˜ํ•œ ํŒŒ์ผ์„ ์•Œ๋ ค์ฃผ๊ฑฐ๋‚˜ ํ…Œ๋งˆ, ํ”Œ๋Ÿฌ๊ทธ์ธ๋“ฑ์˜ ์„ค์ •์„ ํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•˜๋Š” ์—ญํ• ์„ ํ•œ๋‹ค.

import type { Config } from "tailwindcss";

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: {
      backgroundImage: {
        "gradient-radial": "radial-gradient(var(--tw-gradient-stops))",
        "gradient-conic":
          "conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))",
      },
    },
  },
  plugins: [],
};
export default config;

์ฒ˜์Œ ์ƒ์„ฑํ•˜๊ฒŒ ๋˜๋ฉด ์œ„์™€ ๊ฐ™์€ ๊ตฌ์กฐ๋กœ ์ƒ์„ฑ๋˜์–ด ์žˆ๋‹ค.

content ๋Š” ํ•ด๋‹น ๊ฒฝ๋กœ์•ˆ์— tailwind๊ฐ€ ๋ณ€ํ™˜ํ•  ํด๋ž˜์Šค ๋„ค์ž„์ด ์œ„์น˜ํ•˜๊ณ  ์žˆ์Œ์„ ์•Œ๋ ค์ค€๋‹ค. theme์€ ๋‹จ์–ด ๊ทธ๋Œ€๋กœ ํ…Œ๋งˆ๋ฅผ ์„ค์ •ํ•˜๋Š”๋ฐ, extend๋ฅผ ์‚ฌ์šฉํ•ด ๊ธฐ์กด ํ…Œ๋งˆ๋ฅผ ์ƒ์†ํ•ด ์ปค์Šคํ…€ ํ…Œ๋งˆ๋ฅผ ์„ค์ •ํ• ์ˆ˜๋„ ์žˆ๋‹ค. ๋งˆ์ง€๋ง‰์œผ๋กœ plugin์€ ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ์„ ํ™•์žฅํ•˜๋Š”๋ฐ ์‚ฌ์šฉ๋˜๋Š” ํ”Œ๋Ÿฌ๊ทธ์ธ์„ ์„ค์ •ํ•œ๋‹ค.

๊ธฐ๋ณธ์ ์ธ ๊ตฌ์กฐ๋ฅผ ์‚ดํŽด๋ดค์œผ๋‹ˆ ์‹ค์ œ๋กœ ์–ด๋–ค์‹์œผ๋กœ ์‚ฌ์šฉํ•ด์•ผ ํ•˜๋Š”์ง€ ์กฐ๊ธˆ ๋” ์‚ดํŽด๋ณด์ž

import type { Config } from "tailwindcss";

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: {
    colors: {
	primary: '#2a7de1',
	},
    extend: {
      backgroundImage: {
        "gradient-radial": "radial-gradient(var(--tw-gradient-stops))",
        "gradient-conic":
          "conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))",
      },
    },
  },
  plugins: [],
};
export default config;

์œ„ ์˜ˆ์‹œ์™€ ๊ฐ™์ด theme ๋ฐ”๋กœ ํ•˜์œ„์— ์„ค์ •ํ•  ํด๋ž˜์Šค๋ฅผ ์ •์˜ํ•˜๋Š” ๊ฒฝ์šฐ, ๊ธฐ์กด์˜ tailwind์—์„œ ์„ค์ •๋œ ๊ฐ’๋“ค์„ ์‚ฌ์šฉํ• ์ˆ˜ ์—†๋‹ค. ์ข€๋” ์ •ํ™•ํžˆ ๋งํ•˜์ž๋ฉด ๊ธฐ์กด์˜ ์„ค์ •๊ฐ’์„ ๋ฎ์–ด์“ฐ๊ฒŒ ๋œ๋‹ค. ๊ทธ๋ž˜์„œ ๊ธฐ์กด๊ฐ’์„ ์œ ์ง€ํ•˜๋ฉด์„œ ์ปค์Šคํ…€ ๊ฐ’์„ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” extends ํ•˜์œ„์—์„œ ๊ฐ’๋“ค์„ ์„ค์ •ํ•˜๋Š” ๊ฒƒ์ด๋‹ค.

์ฆ‰, ์œ„์˜ ์˜ˆ์‹œ์—์„œ colors ํ•˜์œ„์— ๋‹ค๋ฅธ ๊ฐ’๋“ค์„ ์ง€์ •ํ•˜์ง€ ์•Š์œผ๋ฉด ๊ธฐ์กด์˜ ์ƒ‰ ํด๋ž˜์Šค๋„ค์ž„๋“ค์€ ์‚ฌ๋ผ์ง€๊ณ  primary ๋ผ๋Š” ๊ฐ’๋งŒ ๋‚จ๊ฒŒ๋œ๋‹ค.

theme: {
  screens: {
    'sm': '640px',
    'md': '768px',
    'lg': '1024px',
    'xl': '1280px',
    '2xl': '1536px',
    'mobile': '800px',
  },
}

๋ฐ˜์‘ํ˜• ui๋ฅผ ๊ตฌํ˜„ํ•˜๊ฑฐ๋‚˜, ๋ ˆ์ด์•„์›ƒ์˜ ํฌ๊ธฐ๋ฅผ ์กฐ์ ˆํ•˜๋Š” ๊ฒฝ์šฐ ์‚ฌ์šฉ๋˜๋Š” ํ‚ค์›Œ๋“œ์ธ sm, md,lg ๋“ฑ์˜ ํด๋ž˜์Šค๋„ค์ž„๋„ ์ปค์Šคํ…€์ด ๊ฐ€๋Šฅํ•˜๋‹ค. ๊ธฐ์กด์˜ ํด๋ž˜์Šค๋„ค์ž„์˜ ํฌ๊ธฐ๋ฅผ ์กฐ์ •ํ•˜๊ฑฐ๋‚˜ ์ƒˆ๋กœ์šด ํด๋ž˜์Šค ๋„ค์ž„์„ ์ง€์ •ํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด ์œ„ ์˜ˆ์‹œ์ฒ˜๋Ÿผ screen ํ‚ค์›Œ๋“œ๋ฅผ ์‚ฌ์šฉํ•ด ํฌ๊ธฐ๋ฅผ ์ง€์ •ํ•  ์ˆ˜ ์žˆ๋‹ค.

Previousbase, utility, component, layerNextReact

Last updated 7 months ago