Tematización
Última actualización:
El sistema de temas solo CSS de Frutjam utiliza variables CSS y un único atributo de datos. Cambie temas claros, oscuros y personalizados sin JavaScript. Tokens de color WCAG AA integrados, funcionan con Django, HTMX, Laravel y cualquier proyecto Tailwind CSS v4.
Frutjam se entrega con un sistema de temática Berry: un conjunto de temas con nombre basados en los valores de color de OKLCH. Aplique un tema a toda su aplicación o anide temas dentro de secciones específicas usando el atributo data-theme. Solo CSS, no se requiere JavaScript, accesible a WCAG AA: funciona con Django, HTMX, Laravel, React y cualquier proyecto Tailwind CSS v4.
Temas incorporados
Frutjam incluye dos temas integrados listos para usar:
Baya de nieve (ligera)
El tema claro predeterminado. Se aplica automáticamente cuando no se establece ningún data-theme.
1 2 3 4 5 6 7 | <html data-theme="snowberry"> <!-- or use the alias --> </html> <html data-theme="light"> <!-- same as snowberry --> </html> |
Mora oscura (oscura)
El tema oscuro incorporado.
1 2 3 4 5 6 7 | <html data-theme="darkberry"> <!-- or use the alias --> </html> <html data-theme="dark"> <!-- same as darkberry --> </html> |
Aplicar un tema
Agregue data-theme a cualquier elemento HTML. El tema llega a todos los niños.
1 2 3 4 5 6 | <!-- Apply globally --> <html data-theme="snowberry"> <body> <!-- All components use snowberry theme --> </body> </html> |
Temas anidados
Los temas se pueden anidar: un elemento secundario anula el tema principal de su subárbol.
1 2 3 4 5 6 7 8 9 | <html data-theme="snowberry"> <section data-theme="darkberry"> <!-- This section uses the dark theme --> <button class="btn btn-primary">Dark Button</button> </section> <!-- Back to light theme here --> <button class="btn btn-primary">Light Button</button> </html> |
Variante del modo oscuro
Utilice el prefijo dark: de Tailwind: se activa tanto en data-theme="dark" como en data-theme="darkberry".
1 2 3 | <p class="text-on-base dark:text-primary"> Adapts to the active theme automatically. </p> |
Temas personalizados
Cree su propio tema definiendo variables CSS dentro de un selector [data-theme]. Consulte la página Configuración para obtener la referencia completa de las variables.
1 2 3 4 5 6 7 8 9 10 | @layer theme { :is([data-theme="myberry"]) { --scheme-color: light; --border-radius: 0.5rem; --color-base: oklch(1 0 0); --color-primary: oklch(55% 0.22 142); --color-secondary: oklch(60% 0.18 280); --color-accent: oklch(70% 0.20 60); } } |
1 2 3 | <html data-theme="myberry"> <!-- Your custom theme is active --> </html> |