0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

shadcn/uiで簡単にダークモード対応をする

Last updated at Posted at 2025-01-28

概要

shadcn/uiではダークモード対応のために手順が用意されています。

しかし、上記手順は少々複雑です。システム設定を反映させるだけならもっと簡単な方法があったのでメモします。

以下はremixの場合ですが、他のフレームワークでも使えるかもしれないです。

手順

1. CSS変更

app/tailwind.css

.dark {
  ...
}

@media (prefers-color-scheme: dark) {
  :root {
    ...
  }
}

に書き換える。

2. tailwind設定変更

tailwind.config.tsで、以下をコメントアウト。

// darkMode: ["class"],

もしくは以下に変更。

darkMode: ["media"],

ソース

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?