Tailwind CSS & Theming
Setup & Configuration:
Install Tailwind Dependencies
npm install tailwindcss postcss autoprefixer -D npx tailwindcss init -pConfigure
tailwind.config.jsmodule.exports = { content: ['./frontend/**/*.{js,ts,jsx,tsx}'], theme: { extend: { colors: { primary: 'var(--color-primary)', secondary: 'var(--color-secondary)', }, spacing: {}, }, }, plugins: [], };Define CSS Variables In
frontend/styles/globals.css, declare theme variables::root { --color-primary: #1f2937; --color-secondary: #3b82f6; } [data-theme='dark'] { --color-primary: #111827; --color-secondary: #6366f1; }Enable Theming Toggle
Use Context API or custom hook (
useTheme) to switchdata-themeon<html>.Persist user preference in
localStorage.
Component Styling:
Use utility classes with custom colors:
bg-primary,text-secondary.Create reusable UI tokens in
frontend/src/ui/theme.ts:Leverage shadcn/ui and apply theme overrides via the
classNameprop.
Responsive Design & Accessibility:
Define breakpoints in
tailwind.config.jsundertheme.screens.Ensure all color contrasts meet WCAG AA guidelines.
Last updated