Interactivity

color-scheme

Utilities for controlling the color scheme of an element.

ClassStyles
scheme-normal
color-scheme: normal;
scheme-dark
color-scheme: dark;
scheme-light
color-scheme: light;
scheme-light-dark
color-scheme: light dark;
scheme-only-dark
color-scheme: only dark;
scheme-only-light
color-scheme: only light;

Examples

Basic example

Use utilities like scheme-light and scheme-light-dark to control how element should be rendered:

Try switching your system color scheme to see the difference

scheme-light

scheme-dark

scheme-light-dark

<div class="scheme-light ...">  <input type="date" /></div><div class="scheme-dark ...">  <input type="date" /></div><div class="scheme-light-dark ...">  <input type="date" /></div>

Applying in dark mode

Prefix a color-scheme utility with a variant like dark:* to only apply the utility in that state:

<html class="scheme-light dark:scheme-dark ...">  <!-- ... --></html>

Learn more about using variants in the variants documentation.

Copyright © 2025 Tailwind Labs Inc.·Trademark Policy

Tailwind CSS 中文网(本网站)的目标是为中文开发者提供准确、及时的 Tailwind CSS 中文文档

Tailwind CSS 中文文档由本网站维护人员共同翻译,采用 MIT 开源协议发布

本网站与 tailwindcss.com 及 Tailwind Labs Inc. 并无从属关系

Tailwind 商标由 Tailwind Labs Inc. 所有

京ICP备15031610号-8