GifproGifpro

light-dark() を使ったインタラクティブダークモードトグル

VISTA DE CÓDIGO

P

Prompt

Create an interactive dark mode toggle using the CSS light-dark() function. The page should have a toggle switch that changes between light and dark themes. Use CSS custom properties with light-dark() for all colors. Add smooth transitions and a minimal, clean UI with a card, some text, and a button. The toggle should use a checkbox with a custom style.

このインタラクティブデモは、モダンCSSのlight-dark()関数を紹介しています。この関数を使うと、1つのプロパティ宣言でライトモードとダークモードの両方の値を定義できます。ルート要素にcolor-scheme: light darkを設定することで、ブラウザはユーザーのシステム設定または明示的に設定されたカラースキームに基づいて自動的に適切な値を選択します。トグルスイッチはドキュメントルートのcolor-schemeを動的に変更し、ダーク/ライトテーマの手動オーバーライドを可能にします。すべての色はlight-dark()を使って2つの引数(ライト値とダーク値)で一度だけ定義されます。これにより、メディアクエリやテーマごとのカスタムプロパティが不要で、テーマ管理が非常にシンプルになります。

¿Te resultó útil este prompt?

Comentarios

Los comentarios aparecen después de la moderación

Inicioヘルプ