<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Dark-Mode on Commentary of Takao</title><link>https://takao.blog/es/tags/dark-mode/</link><description>Recent content in Dark-Mode on Commentary of Takao</description><generator>Hugo -- gohugo.io</generator><language>es</language><copyright>Commentary of Takao</copyright><lastBuildDate>Sun, 12 Jul 2026 04:12:51 +0900</lastBuildDate><atom:link href="https://takao.blog/es/tags/dark-mode/index.xml" rel="self" type="application/rss+xml"/><item><title>Implementando modo oscuro simple con CSS light-dark()</title><link>https://takao.blog/es/web/css-light-dark-color-scheme/</link><pubDate>Fri, 10 Oct 2025 00:00:00 +0900</pubDate><guid>https://takao.blog/es/web/css-light-dark-color-scheme/</guid><description>&lt;img src="https://takao.blog/img/thumbnail/css-light-dark-color-scheme-es.png" alt="Featured image of post Implementando modo oscuro simple con CSS light-dark()" /&gt;&lt;h2 id="el-problema-del-modo-oscuro-tradicional"&gt;El problema del modo oscuro tradicional
&lt;/h2&gt;&lt;p&gt;Tradicionalmente requería reglas CSS duplicadas en &lt;code&gt;@media (prefers-color-scheme: dark)&lt;/code&gt;. &lt;code&gt;light-dark()&lt;/code&gt; elimina esta duplicación.&lt;/p&gt;
&lt;h2 id="la-función-light-dark"&gt;La función light-dark()
&lt;/h2&gt;&lt;p&gt;Acepta dos colores y retorna el que coincide con el esquema actual del usuario: &lt;code&gt;color: light-dark(black, white)&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id="configuración-de-color-scheme"&gt;Configuración de color-scheme
&lt;/h2&gt;&lt;p&gt;Requiere declarar los esquemas soportados: &lt;code&gt;color-scheme: light dark;&lt;/code&gt; en &lt;code&gt;:root&lt;/code&gt; o mediante &lt;code&gt;&amp;lt;meta name=&amp;quot;color-scheme&amp;quot;&amp;gt;&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id="variables-de-tema-simplificadas"&gt;Variables de tema simplificadas
&lt;/h2&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-css" data-lang="css"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;:&lt;span style="color:#a6e22e"&gt;root&lt;/span&gt; { --bg: &lt;span style="color:#a6e22e"&gt;light-dark&lt;/span&gt;(&lt;span style="color:#ae81ff"&gt;#ffffff&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;#1a1a2e&lt;/span&gt;); --text: &lt;span style="color:#a6e22e"&gt;light-dark&lt;/span&gt;(&lt;span style="color:#ae81ff"&gt;#111111&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;#e0e0e0&lt;/span&gt;); }
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Sin media queries. El navegador maneja el cambio automáticamente.&lt;/p&gt;</description></item></channel></rss>