Framework CSS utility-first interno que genera automáticamente clases desde design tokens JSON, gestionando colores, tipografía y responsividad.
html
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Ejemplo Framework CSS Utility-First</title>
<style>
/*
Framework CSS Utility-First Interno
Generación automática desde Design Tokens
----------------------------------------
Este archivo contiene las clases CSS generadas automáticamente a partir de los design tokens definidos en JSON.
Cada clase está comentada en italiano para facilitar su comprensión y mantenimiento.
*/
/*
COLORES
Definición de utilidades para colores de fondo y texto basadas en design tokens.
*/
.bg-primary { background-color: #1E40AF; /* Blu primario */ }
.bg-secondary { background-color: #9333EA; /* Viola secondario */ }
.bg-success { background-color: #10B981; /* Verde successo */ }
.bg-danger { background-color: #EF4444; /* Rosso per errori */ }
.bg-warning { background-color: #F59E0B; /* Giallo avviso */ }
.bg-info { background-color: #3B82F6; /* Azzurro informativo */ }
.text-primary { color: #1E40AF; /* Testo blu primario */ }
.text-secondary { color: #9333EA; /* Testo viola secondario */ }
.text-success { color: #10B981; /* Testo verde successo */ }
.text-danger { color: #EF4444; /* Testo rosso errore */ }
.text-warning { color: #F59E0B; /* Testo giallo avviso */ }
.text-info { color: #3B82F6; /* Testo azzurro informativo */ }
/*
ESPACIADOS
Utilidades para margin y padding basadas en escala de espaciado.
m = margin, p = padding, seguido de t (top), r (right), b (bottom), l (left), x (left+right), y (top+bottom)
El número indica el tamaño basado en la escala definida en los tokens.
*/
.m-0 { margin: 0; }
.m-1 { margin: 0.25rem; /* 4px */ }
.m-2 { margin: 0.5rem; /* 8px */ }
.m-3 { margin: 0.75rem; /* 12px */ }
.m-4 { margin: 1rem; /* 16px */ }
.m-5 { margin: 1.25rem; /* 20px */ }
.m-6 { margin: 1.5rem; /* 24px */ }
.mt-1 { margin-top: 0.25rem; }
.mr-1 { margin-right: 0.25rem; }
.mb-1 { margin-bottom: 0.25rem; }
.ml-1 { margin-left: 0.25rem; }
.mx-2 { margin-left: 0.5rem; margin-right: 0.5rem; }
.my-3 { margin-top: 0.75rem; margin-bottom: 0.75rem; }
.p-0 { padding: 0; }
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-5 { padding: 1.25rem; }
.p-6 { padding: 1.5rem; }
.pt-1 { padding-top: 0.25rem; }
.pr-1 { padding-right: 0.25rem; }
.pb-1 { padding-bottom: 0.25rem; }
.pl-1 { padding-left: 0.25rem; }
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
/*
TIPOGRAFÍA
Utilidades para tamaño de fuente, peso y alineación.
*/
.text-xs { font-size: 0.75rem; /* 12px */ }
.text-sm { font-size: 0.875rem; /* 14px */ }
.text-base { font-size: 1rem; /* 16px */ }
.text-lg { font-size: 1.125rem; /* 18px */ }
.text-xl { font-size: 1.25rem; /* 20px */ }
.text-2xl { font-size: 1.5rem; /* 24px */ }
.font-thin { font-weight: 100; }
.font-light { font-weight: 300; }
.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-extrabold { font-weight: 800; }
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }
/*
DISPLAY Y LAYOUT
Utilidades para display, flexbox y grid.
*/
.block { display: block; }
.inline-block { display: inline-block; }
.inline { display: inline; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.grid { display: grid; }
.hidden { display: none; }
.flex-row { flex-direction: row; }
.flex-row-reverse { flex-direction: row-reverse; }
.flex-col { flex-direction: column; }
.flex-col-reverse { flex-direction: column-reverse; }
.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }
.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.items-stretch { align-items: stretch; }
/*
PUNTOS DE INTERRUPCIÓN RESPONSIVE
Prefijos para aplicar utilidades en anchos específicos de viewport.
sm: min-width 640px
md: min-width 768px
lg: min-width 1024px
xl: min-width 1280px
*/
@media (min-width: 640px) {
.sm\:text-center { text-align: center; }
.sm\:flex { display: flex; }
.sm\:p-4 { padding: 1rem; }
/* Otras utilidades responsive sm */
}
@media (min-width: 768px) {
.md\:text-left { text-align: left; }
.md\:grid { display: grid; }
.md\:m-6 { margin: 1.5rem; }
/* Otras utilidades responsive md */
}
@media (min-width: 1024px) {
.lg\:flex-row { flex-direction: row; }
.lg\:text-xl { font-size: 1.25rem; }
/* Otras utilidades responsive lg */
}
@media (min-width: 1280px) {
.xl\:p-6 { padding: 1.5rem; }
.xl\:font-bold { font-weight: 700; }
/* Otras utilidades responsive xl */
}
/*
FIN DEL FRAMEWORK CSS
Todas las clases son generadas automáticamente desde design tokens JSON.
Para modificar colores, espacios o tipografía, actualice los tokens y regenere el CSS.
*/
</style>
</head>
<body class="bg-primary text-info p-4">
<header class="mb-4">
<h1 class="text-2xl font-extrabold text-center">Ejemplo de Framework CSS Utility-First</h1>
</header>
<section class="bg-secondary p-4 rounded text-white">
<p class="text-base font-medium mb-3">Este es un bloque con fondo secundario y texto blanco.</p>
<button class="bg-success text-white px-4 py-2 rounded font-semibold hover:bg-success">Botón de éxito</button>
</section>
<section class="mt-6 p-4 bg-info text-primary rounded flex flex-col sm:flex-row justify-between items-center">
<div class="mb-3 sm:mb-0">
<p class="font-light text-sm">Texto alineado a la izquierda en md y centrado en sm.</p>
</div>
<div>
<button class="bg-danger text-white p-2 rounded font-bold">Botón de error</button>
</div>
</section>
<footer class="mt-8 text-center text-warning font-semibold">
<p>Pie de página con texto de advertencia.</p>
</footer>
</body>
</html>Design Tokens: JSON que contiene colores, espacios, fuentes y puntos de interrupción
Generador CSS: script (hipotético) que transforma los design tokens en clases CSS utility-first
Utility CSS: clases generadas para colores de fondo, texto, márgenes, padding, tamaño de fuente, peso de fuente, display, flexbox, grid y responsive
Configuración Responsive: puntos de interrupción definidos y usados para generar variantes responsive de las utilities
Documentación interna: comentarios en italiano para cada sección y clase
Arduino Wiring/Pinout: no aplicable (framework CSS, no hardware)
Dependencias/Configuración Software: Node.js para ejecución del script de generación, JSON para design tokens, sin librerías externas obligatorias