깜놀하는 해므찌로

tailwind 컬러 등록 자동화 예시 / generateColor 본문

IT

tailwind 컬러 등록 자동화 예시 / generateColor

agnusdei1207 2023. 6. 15. 17:30
반응형
SMALL
npm install --force @nextcss/color-tools

1. 설치

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: ["./src/**/*.{html,ts}"],
  theme: {
    extend: {
      colors: {
        primary: generateColors("#001650"),
      },
    },
  },
  plugins: [],
};

function generateColors(color) {
  const { toneMap } = require("@nextcss/color-tools");
  return {
    DEFAULT: color,
    ...toneMap(color),
  };
}

2. tailwind.config.js 내부에 컬러 생성 메소드 선언 및 호출

 

 

반응형
LIST