Theme

Theme๋ž€?

์†Œํ”„ํŠธ์›จ์–ด์—์„œ ์‚ฌ์šฉ๋˜๋Š” UI์˜ ์™ธ๊ด€ ๋ฐ ๋™์ž‘์— ๊ด€ํ•œ ์„ธ๋ถ€ ์ •๋ณด๋ฅผ ํฌํ•จํ•˜๋Š” ์ง‘ํ•ฉ

์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋‚ด์˜ ๋นˆ๋ฒˆํ•˜๊ฒŒ ์‚ฌ์šฉ๋˜๋Š” ์Šคํƒ€์ผ ๊ฐ’์„ ํ•œ ๊ณณ์—์„œ ์ •์˜ํ•˜๊ณ  ๊ด€๋ฆฌํ•˜์—ฌ ์ผ๊ด€์„ฑ๊ณผ ์œ ์ง€๋ณด์ˆ˜์„ฑ์„ ๋†’ํž˜

์ฆ‰, ๋””์ž์ธ ์‹œ์Šคํ…œ์— ์ •์˜๋œ ํฐํŠธ, ์ƒ‰์ƒ, ๊ฐ„๊ฒฉ ๋“ฑ์˜ ๋””์ž์ธ ์š”์†Œ๋“ค์„ ์ „์—ญ์œผ๋กœ ์„ ์–ธํ•˜์—ฌ ์‚ฌ์šฉํ•˜๋Š”๊ฒƒ์„ ๋งํ•œ๋‹ค.

๋””์ž์ธ ์‹œ์Šคํ…œ(Design System)์ด๋ž€ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋‚ด์—์„œ ์‚ฌ์šฉ๋˜๋Š” ๋””์ž์ธ ์š”์†Œ๋ฅผ ์ผ๊ด€์„ฑ ์žˆ๊ฒŒ ์œ ์ง€ํ•˜๊ณ  ๊ด€๋ฆฌํ•˜๋Š” ํ”„๋ ˆ์ž„์›Œํฌ

tailwind.config.js theme ์†์„ฑ์œผ๋กœ ์—ฌ๋Ÿฌ๊ฐ€์ง€ ์ „์—ญ ์Šคํƒ€์ผ์„ ์ •์˜ํ•  ์ˆ˜ ์žˆ๋‹ค.

Theme Property

  • colors: ์ƒ‰์ƒ ๊ฐ’์„ ์ •์˜ํ•˜๋Š” ๊ฐ์ฒด

  • fontFamily: ๊ธ€๊ผด ํŒจ๋ฐ€๋ฆฌ ๊ฐ’์„ ์ •์˜ํ•˜๋Š” ๊ฐ์ฒด

  • fontSize: ๊ธ€๊ผด ํฌ๊ธฐ ๊ฐ’์„ ์ •์˜ํ•˜๋Š” ๊ฐ์ฒด

  • fontWeight: ๊ธ€๊ผด ๋‘๊ป˜ ๊ฐ’์„ ์ •์˜ํ•˜๋Š” ๊ฐ์ฒด

  • lineHeight: ์ค„ ๊ฐ„๊ฒฉ ๊ฐ’์„ ์ •์˜ํ•˜๋Š” ๊ฐ์ฒด

  • borderRadius: ๋ชจ์„œ๋ฆฌ ๋‘ฅ๊ธ€๊ธฐ ๊ฐ’์„ ์ •์˜ํ•˜๋Š” ๊ฐ์ฒด

  • boxShadow: ๊ทธ๋ฆผ์ž ๊ฐ’์„ ์ •์˜ํ•˜๋Š” ๊ฐ์ฒด

  • extend: ์œ ํ‹ธ๋ฆฌํ‹ฐ ํด๋ž˜์Šค๋ฅผ ๋ฎ์–ด์“ฐ๊ฑฐ์ด ํ™•์žฅํ•˜๋Š” ๊ฐ์ฒด

  • ์ด ์™ธ์—๋„ ๋Œ€๋ถ€๋ถ„์˜ CSS ์†์„ฑ๋“ค ๋ชจ๋‘ ์ปค์Šคํ…€์ด ๊ฐ€๋Šฅํ•˜๋‹ค.

module.exports = {
  theme: {
    extend: {},
    screens: {
      md: '768px',
      lg: '1040px',
    },
    fontFamily: {
      rubik: ['Rubik Pixels', 'cursive'],
    },
  },
};

screens

๋ฏธ๋””์–ด ์ฟผ๋ฆฌ์— ๋”ฐ๋ฅธ ๋ฐ˜์‘ํ˜•(๋ธŒ๋ ˆ์ดํฌ ํฌ์ธํŠธ) ํด๋ž˜์Šค๋ฅผ ์„ค์ •

๊ธฐ๋ณธ์ ์œผ๋กœ min-width ํ˜•์‹์œผ๋กœ ์ ์šฉ๋œ๋‹ค.

@media (min-width: **px) {}

default theme

  • sm โ†’ 640px

  • md โ†’ 768px

  • lg โ†’ 1024px

  • xl โ†’ 1280px

  • 2xl โ†’ 1536px

Custom

module.export = {
  theme: {
    screens: {
      md: '768px',
      lg: '1098px',
    },
  }
}

Usage

<!-- [mobile] blue , green, yellow, red [desktop] -->
<button class="bg-blue-500 sm:bg-green-500 md:bg-yellow-500 lg:bg-red-500">button</button>

fontFamily

์‚ฌ์šฉ์ž ํฐํŠธ ํด๋ž˜์Šค๋ฅผ ์„ค์ •

Custom

๋ฐฐ์—ด ์ˆœ์„œ๋Œ€๋กœ ํฐํŠธ๋ฅผ ์ฐพ์•„ ๋ Œ๋”๋งํ•˜๊ฒŒ ๋จ

module.exports = {
  theme: {
    fontFamily: {
      'myFont': ['Rubik Pixels', 'cursive']
    }
  }
}

Usage

<button class="font-myFont">button</button>

์ž„์˜์˜ ๊ฐ’ ์‚ฌ์šฉํ•˜๊ธฐ

์ด๋ฏธ ์ •์˜๋œ ํด๋ž˜์Šค๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹Œ ์‚ฌ์šฉ์ž๊ฐ€ ์ง์ ‘ ๊ฐ’์„ ์ง€์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•

[] ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋Œ€๊ด„ํ˜ธ ์•ˆ์— ์ž„์˜์˜ ๊ฐ’์„ ์ ์šฉํ•˜์—ฌ ์‚ฌ์šฉํ•œ๋‹ค.

Usage

<button class="bg-[#0066ff] w-[30px]">button</button>

Last updated