Post

TailwindCSS ์„ธํŒ…(2) - Tailwind Color Custom

๐Ÿ“Œ์‹œ์ž‘ํ•˜๋ฉฐ

TailwindCSS ์„ธํŒ…(1)ํŽธ์—์„œ plugin์ด๋‚˜ ๊ทธ ์™ธ ์„ธํŒ…์„ ๋งˆ๋ฌด๋ฆฌ ํ–ˆ์œผ๋‹ˆ ์ด๋ฒˆ์—” tailwind ์ปฌ๋Ÿฌ๋ฅผ ์ปค์Šคํ…€ ํ•ด๋ณด๊ณ ์ž ํ•œ๋‹ค. ์‚ฌ์‹ค ๊ฑฐ์ฐฝํ•ด๋ณด์ด์ง€๋งŒ ๋ณ„ ๊ฑด ์—†๋‹ค๐Ÿคญ

์ด ๊ธ€์€ ์•„๋ž˜์™€ ๊ฐ™์ด ์ด์–ด์ง‘๋‹ˆ๋‹ค.

โœ… ํ•„์š”ํ•œ color ์ถ”๊ฐ€ํ•˜๊ธฐ

tailwind ์—์„œ ๊ธฐ๋ณธ์œผ๋กœ ์ œ๊ณตํ•˜๋Š” color๋„ ์ถฉ๋ถ„ํžˆ ์˜ˆ์˜์ง€๋งŒ, ๋‚ด ํ”„๋กœ์ ํŠธ์—๋Š” ๋งž์ง€ ์•Š์„ ์ˆ˜ ์žˆ๋‹ค. ์ด๋Ÿด ๋• color ๊ฐ’์„ ์ถ”๊ฐ€ํ•ด์ฃผ๋ฉด ๋œ๋‹ค. ๋‚˜๋Š” music ์ด๋ž€ ์ด๋ฆ„์œผ๋กœ ์ปฌ๋Ÿฌ๊ฐ’๋“ค์„ ์ถ”๊ฐ€ํ•ด์ฃผ์—ˆ๋‹ค. ์ง์ ‘ ์ ์šฉํ•  ๋•Œ๋Š” bg-music-100 ์ด๋Ÿฐ์‹์œผ๋กœ ์ ์šฉํ•˜๋ฉด ๋œ๋‹ค.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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: {
    colors: {
      music: { ๐Ÿ‘ˆ
        100: "#E9F6FC",
        //์—ฌ๊ธฐ์— ๋” ์ถ”๊ฐ€ํ•ด์ฃผ๋ฉด ๋œ๋‹ค.
      },
    },
  },
}
export default config

โœ… ๊ธฐ๋ณธ color ํ•จ๊ป˜ ์‚ฌ์šฉํ•˜๊ธฐ

๊ทธ๋Ÿฐ๋ฐ ์œ„์˜ ๋‚ด์šฉ๊นŒ์ง€๋งŒ ํ•˜๊ณ  ๋๋‚ด๋ฉด ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•œ๋‹ค. ๋‚˜๋Š” gray๋‚˜ black๊ณ„์—ด์€ ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉํ•  ์ƒ๊ฐ์ด์—ˆ๋Š”๋ฐ, ์ €๋ ‡๊ฒŒ color๋ฅผ ์ž‘์„ฑํ•˜๋ฉด ๊ธฐ์กด์˜ color๊ฐ’๋“ค์€ ์‚ฌ์šฉ์ด ๋ถˆ๊ฐ€๋Šฅํ•ด์ง„๋‹ค. ํ•˜์ง€๋งŒ ์นœ์ ˆํ•œ tailwind๋Š” ๊ธฐ์กด color ๊ฐ’๋„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ์ œ์‹œํ•ด์ค€๋‹ค.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import colors from "tailwindcss/colors"  ๐Ÿ‘ˆ

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: {  ๐Ÿ‘ˆ
      //๊ธฐ์กด๊ฐ’๋“ค์„ ๋ถˆ๋Ÿฌ์™€์ค€๋‹ค.
      transparent: "transparent",
      current: "currentColor",
      black: colors.black,
      white: colors.white,
      gray: colors.gray,
      emerald: colors.emerald,
      indigo: colors.indigo,
      yellow: colors.yellow,
      music: {
        100: "#E9F6FC",
        //์ด ๋ถ€๋ถ„์€ ์ปค์Šคํ…€
      },
    },
  },
}
export default config

๐Ÿ“ฉ๋งˆ๋ฌด๋ฆฌ

๋‹ค์Œ์—” ์ž์ฃผ ์‚ฌ์šฉํ•˜๋Š” css ๋‚ด์šฉ์„ ์ •๋ฆฌํ•ด๋ณด๊ณ ์ž ํ•œ๋‹ค!

๐Ÿ—‚๏ธ์ฐธ๊ณ  ์‚ฌ์ดํŠธ

This post is licensed under CC BY 4.0 by the author.