tailwind.config.js 파일을 통해 다크 모드 설정시 적용이 되지 않습니다.
315
작성한 질문수 8
[tailwind.config.js]
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ['./src/**/*.{html,js}'],
darkMode: 'selector',
};
[practice-test.html]
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Tailwind CSS</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-white dark:bg-gray-900 dark:text-white">
<main
class="container max-w-5xl mx-auto min-h-screen flex items-center justify-center"
>
<div class="flex flex-col items-center">
<h1 class="font-extrabold text-3xl">Tailwind CSS 다크모드</h1>
<p class="mt-4">이 페이지는 다크 모드를 지원합니다.</p>
<button
id="darkmode_btn"
class="bg-blue-500 px-4 py-2 rounded-md text-white mt-4"
>
다크 모드 전환
</button>
<div
class="px-10 py-6 bg-white rounded-md shadow-md mt-20 dark:bg-gray-800"
>
<p>이 박스는 다크 모드에서 배경이 어두운 색으로 변합니다.</p>
</div>
</div>
</main>
<script>
document.querySelector('#darkmode_btn').addEventListener('click', () => {
document.documentElement.classList.toggle('dark');
});
</script>
</body>
</html>
tailwind.config.js 의 경로는 아래 스크린샷으로 첨부하였습니다.

제가 무슨 설정을 빠트린건지 명확히는 모르겠는데 <head> 태그 내부에 <script> 태그로 아래와 같이 설정하면 버튼을 클릭했을 때 다크모드와 원래 상태로 정상적으로 토글이 되는데 tailwind.config.js 로 설정만 하면 토글이 안되네요 모든 페이지에 다크모드를 설정하기 위해서는 tailwind.config.js 를 통해서 다크 모드 활성화를 하는 것이 좋을 것 같아서 질문 남깁니다! 좋은 강의 감사드립니다.
tailwind.config = { // darkMode: 'media', // 운영 체제의 모드에 맞게 설정 darkMode: 'selector', // 수동으로 설정 };
답변 1
0
CDN으로 tailwind 를 설치했을 경우에는 tailwind.config 설정을 해당 파일 안에 하셔야돼요~!
tailwind.config.js 파일은 tailwind intellisense를 위한 파일입니다.
Dark Mode 설정 회차를 한번 더 보시는 것을 권장드립니다.
수업자료와 노션 공유 문제
0
16
3
안녕하세요 한번 더 문의드립니다.
0
22
2
git 초기설정하고 Next Js 설치하는게 너무 어렵습니다.
0
13
1
81강 실습 자료 없음
0
27
2
궁금했던 질문입니다. 바로 콤마위치 입니다.
0
25
1
선생님 공유해주신 핸드북에 링크가 몇개 잘못되었어요
0
27
2
62강 실습자료가 잘못되었습니다.
0
25
1
코드 자료는 없는걸까요?
0
55
3
강의 목표
0
36
1
강의 노트 위주로 학습
0
40
1
[무료 강의] AI로 브랜드 가이드라인, 디자인 시스템 구축부터, 앱 제작, 피칭 덱, 카드 캐러셀까지
0
34
1
tailwindcss v4.1 에서의 script 사용에 대해 궁금한 점이 있습니다.
1
119
1
확장 프로그램 설치 및 최적화 버전 문의
1
114
2
tailwindcss 와 ai tool
0
100
1
tailwindcss 4.1 docs에서는 container가 목록에서 안보이네요
0
95
2
quasar와 tailwind 조합에 관한 질문
0
112
1
실습에 사용되는 이미지
0
117
2
모바일 사이즈에 대해 질문있습니다.
0
92
1
nested 리스트일때 <ul> bullet 스타일 바꾸는 방법
0
217
2
via.placeholder.com 오류
0
872
2
빈 화면에서 tail 만 쳤을때 팝업도움말 나오게 하는 법 알려주세요.
0
139
2
수강평 이벤트
0
156
2
font-weight가 왜 적용이 안될까요?
0
437
3
스니펫 관련질문
0
151
1





