Implementing Utility-First CSS for Your Website
After yet another CSS refactoring, we lost count of overridden styles. Every new block required fresh classes, the style.css file bloated to 15 KB, and any change triggered a chain of edits. The solution: Utility-First CSS.
This approach applies styles directly in HTML using pre-built utility classes: flex items-center text-lg bg-blue-500. No more unnecessary file switching, no style bloat. We integrate Tailwind CSS—the most popular implementation—and configure design tokens so the project looks uniform and loads fast. This approach is described in the Tailwind CSS documentation. In practice, layout speed increases by 2–3 times, and the CSS bundle shrinks to 8–25 KB (gzip).
Why Tailwind CSS is not just a trend?
With over 10+ years and hundreds of projects, we've seen custom CSS grow exponentially. The utility approach breaks this pattern—new components reuse the same classes, and the cascade can't break anything. Tailwind is not a framework but a build system: it generates only what is actually used in the project.
How Utility-First CSS Speeds Up Development
The main reason: CSS stops growing linearly. Instead of inventing class names, the developer focuses on layout. All margins, colors, and typography are defined through a unified design token system. This eliminates 'sticky' styles—changing one component no longer breaks another. We guarantee that migrating an existing project to Tailwind will take 1–3 days depending on volume, and we can configure a new project in half a day.
How We Configure Tailwind CSS for Your Project
We use the latest Tailwind CSS 4, where configuration is done directly in CSS. Below is a minimal setup for Vite.
npm install tailwindcss @tailwindcss/vite
// vite.config.ts
import tailwindcss from '@tailwindcss/vite'
import { defineConfig } from 'vite'
export default defineConfig({
plugins: [tailwindcss()],
})
/* src/styles/globals.css */
@import 'tailwindcss';
@theme {
--color-primary: #2563eb;
--color-primary-foreground: #ffffff;
--color-secondary: #f1f5f9;
--color-secondary-foreground: #0f172a;
--color-destructive: #ef4444;
--color-muted: #f8fafc;
--color-border: #e2e8f0;
--radius-sm: 4px;
--radius-md: 8px;
--radius-lg: 12px;
--radius-full: 9999px;
--font-sans: 'Inter', system-ui, sans-serif;
--font-mono: 'JetBrains Mono', monospace;
--shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
--shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}
Components with Tailwind: Product Card Example
Using utilities, we assemble UI components without extra CSS files.
function ProductCard({ product }: { product: Product }) {
return (
<article className="group flex flex-col bg-white rounded-xl border border-slate-200 overflow-hidden shadow-card hover:shadow-md transition-shadow duration-200">
<div className="relative aspect-video overflow-hidden bg-slate-100">
<img src={product.image} alt={product.name} className="w-full h-full object-cover group-hover:scale-105 transition-transform duration-300" />
{product.badge && (
<span className="absolute top-3 left-3 px-2 py-0.5 text-xs font-semibold bg-primary-600 text-white rounded-full">
{product.badge}
</span>
)}
</div>
<div className="flex flex-col gap-3 p-5 flex-1">
<h3 className="font-semibold text-slate-900 leading-snug line-clamp-2">{product.name}</h3>
<p className="text-sm text-slate-500 line-clamp-3 flex-1">{product.description}</p>
<div className="flex items-center justify-between pt-2 border-t border-slate-100">
<span className="text-xl font-bold text-slate-900">{product.price} ₽</span>
<button className="px-4 py-2 text-sm font-medium bg-primary-600 text-white rounded-lg hover:bg-primary-700 active:scale-95 transition-all">Add to cart</button>
</div>
</div>
</article>
)
}
@apply: When to Extract Repeated Classes
If the same utilities appear frequently, we group them via @apply in the components layer. We use it sparingly—only for stable patterns like buttons and inputs. For example, this is how base button and input styles are created, reducing duplication.
Responsiveness Without Media Queries
Tailwind uses mobile-first. No prefix applies to all screens, md: for 768px and up, xl: for 1280px and up. Example: a grid going from 1 to 3 to 4 columns.
<div class="grid grid-cols-1 gap-4 md:grid-cols-3 xl:grid-cols-4">
<!-- cards -->
</div>
Text resizes automatically: text-2xl on mobile, lg:text-4xl on desktop. Hide an element on mobile with hidden md:block.
Adopting Utility-First CSS on an Existing Project
A step-by-step plan from our engineers:
- Audit current styles—determine which classes and custom properties can be replaced with utilities.
- Configure design tokens—map colors, spacing, fonts into
@theme.
- Gradually replace components—start with core (buttons, cards), then the rest.
- Enable dark mode—via attribute or
prefers-color-scheme.
- Build and optimize—verify the bundle didn't bloat and fix dynamic classes.
We guarantee that after migration, CSS will be 3–4 times smaller, and the speed of building new pages will double. Want to see for yourself? Order an audit of your project—we'll send a report with an implementation plan.
Why Tailwind CSS Over Other Utility Frameworks?
Alternatives exist: UnoCSS, Windi CSS, Open Props. But Tailwind stands out for API stability, a huge community, and support in major frameworks. A comparison with traditional methodologies makes the difference clear.
Comparison of Approaches
| Criterion |
Utility-First (Tailwind) |
Traditional (BEM, OOCSS) |
| Development speed |
High—no file switching |
Medium—need to invent classes and write separate CSS |
| CSS bundle size |
8–25 KB gzip (only used) |
30–100+ KB (grows with components) |
| Customization |
Via design tokens and config |
Via variables or overrides |
| Responsiveness |
Built-in prefixes (mobile-first) |
Manual media queries |
| Dark mode support |
One line in config |
Requires overriding all components |
Estimated Timelines and Phases
| Phase |
Duration |
| Audit and design token setup |
0.5–1 day |
| Migration of existing components |
1–2 days |
| Dark mode and responsiveness |
0.5 day |
| Testing and bundle optimization |
0.5 day |
What Our Work Includes
- Installation and configuration of Tailwind CSS (v3 or v4).
- Design token setup (colors, typography, spacing, shadows).
- Creation of base components via
@apply or CVA.
- Dark mode and responsive grid integration.
- Refactoring of existing styles during migration.
- Performance testing (Core Web Vitals).
Estimated timelines: new project setup—from 0.5 day. Existing project migration—1–3 days depending on CSS volume. Pricing is determined after analysis. Contact us to discuss your project: we will respond within an hour and propose an action plan.
Frontend Development with React: From Audit to Production
Bundle grew to 3.1 MB gzip — that's a real figure from a project that came to us for an audit. The cause: moment.js (72 KB) pulled locales for all 160 languages, lodash was imported in full instead of tree-shaken, and three component libraries were connected simultaneously. TTFB was excellent, but TTI on mobile was 14 seconds. Users left, conversion dropped by 40%. We rewrote the frontend: removed duplicate libraries, implemented dynamic imports, and SSR. Result: bundle reduced to 850 KB gzip, TTI to 2.1 seconds, LCP to 1.8 s.
Frontend is not about "drawing prettily". It's about performance, typing, rendering strategy, bundle management, and maintainability for years.
Why is Next.js the Standard Choice for SEO?
React is our primary UI framework for complex interfaces. Next.js is the standard choice for projects with SEO requirements or SSR. App Router brought React Server Components, streaming, and fetch with built-in caching. Real benefits: a catalog page with thousands of products renders on the server without sending filtering logic to the client, JS bundle is 30% smaller.
But App Router is a different way of thinking. "use client" must be placed consciously. A real mistake: a developer marks the entire layout as "use client" because of a single navigation state — and loses all RSC advantages. Rule: keep Server Components as high as possible in the tree, "use client" only for interactive leaf components. ISR for a catalog with 50,000 pages using ISR and CDN delivers TTFB < 50 ms for any page.
How Does TypeScript Prevent Bugs in Production?
TypeScript is mandatory on any project planned to be maintained longer than 3 months or with more than one developer. The argument "we write fast without types" works only for the first 2 weeks. After that, bugs related to undefined values appear every week.
Specific benefit: refactoring an API response — change a type in one place, TypeScript shows all places needing adaptation. Without types, a production bug appears in a week. strict: true in tsconfig.json is mandatory. noImplicitAny, strictNullChecks, strictFunctionTypes. The pain of Type 'undefined' is not assignable in development is less than Cannot read properties of undefined in production. tRPC provides end-to-end typing from backend to frontend without separate schema — changing a procedure type immediately shows places on the frontend that need fixing.
Vue 3 + Nuxt 3 — An Alternative SSR Stack
Vue 3 with Composition API offers a different development style, closer to React Hooks. <script setup> and composables make code more reusable. Nuxt 3 is a framework for Vue with SSR/SSG, similar to Next.js. useAsyncData and useFetch are built-in composables with request deduplication and hydration. Auto-imports are convenient but can confuse during debugging. Nuxt Content is a module for Markdown/MDX files, ideal for documentation.
Hydration mismatch is a specific pain of SSR in Vue and React. Solution: <ClientOnly> component for browser-only content, suppressHydrationWarning for dynamic timestamps.
Performance: Metrics and Tools
Bundle analysis is the starting point. @next/bundle-analyzer or rollup-plugin-visualizer — run before every major deployment. Goal: no page should require > 200 KB JS gzip for first paint.
Dynamic imports for heavy components:
const RichEditor = dynamic(() => import('@/components/RichEditor'), {
ssr: false,
loading: () => <EditorSkeleton />,
});
Editor (Tiptap, Quill, CodeMirror) are typical candidates for dynamic import. Without this, they end up in the main bundle. React DevTools Profiler for finding unnecessary re-renders. React.memo, useMemo, useCallback are targeted tools. Premature memoization of everything adds overhead without benefit. Profile first, optimize later.
Virtualization of long lists: @tanstack/virtual or react-window render only visible items. Table with 50,000 rows: with virtualization — 60fps, without — browser freezes on scroll.
State Management: Without Overengineering
For most applications, it's enough to have:
-
React Query / TanStack Query — for server state (API data, caching, invalidation)
-
Zustand — for global client state (lightweight, no Redux boilerplate)
-
React Hook Form — for forms
Redux Toolkit is justified for very complex global state with many interactions. For most tasks, it's overkill. Recoil, Jotai — atomic approaches for independent pieces of state.
How to Choose the Right CSS and Design System?
Tailwind CSS latest version is our standard choice for new projects. Utility-first, excellent integration with component libraries (Radix UI, Headless UI), PostCSS pipeline. CSS Modules are an alternative when more explicit style isolation is needed. Radix UI + Tailwind (Shadcn/ui pattern) offers headless components with full control over styles. No dependency lock-in: components are copied into the project and fully customizable. Storybook is used for documenting the component library.
React DevTools Profiler — the official tool from the React team.
Testing
| Level |
Tool |
What We Test |
| Unit |
Vitest |
Utilities, hooks, pure functions |
| Component |
Testing Library |
Render, interactions |
| E2E |
Playwright |
Critical user flows |
| Visual |
Chromatic (Storybook) |
UI regression |
E2E tests via Playwright — for checkout, authentication, critical forms. Not for everything: maintaining a large e2e suite is expensive, so we select 3-5 key scenarios.
What's Included in the Scope (Deliverables)
Every frontend project we deliver includes:
-
Source code in Git with full commit history and branching strategy
-
Architecture document — component tree, data flow, routing decisions
-
Component documentation – Storybook with stories for all reusable components
-
CI/CD pipeline – automated builds, linting, tests, deployment config (Vercel / Netlify / custom)
-
Access to staging environment during development and after launch
-
Team training – 2‑3 live walkthrough sessions with your developers
-
3‑month warranty on any bugs found in production
-
Performance report – LCP, TTI, TTFB, bundle size before/after
We also provide a pre‑deployment checklist covering browser testing, security headers, cookie compliance, and accessibility audit.
Estimates and Scope
| Task |
Timeline |
| SPA (dashboard, CRM interface) |
8–16 weeks |
| Next.js site with SSR/ISR |
6–14 weeks |
| Frontend for existing API |
4–10 weeks |
| Component library (design system) |
6–12 weeks |
Cost is calculated after decomposition into components, screens, and API integration. We use N+1 estimation: add 20% for risks.
What Does a Typical Performance Audit Reveal?
A recent e‑commerce project had LCP of 4.2 seconds and a monthly cloud bill of $3,000. After moving to edge‑caching (ISR + CDN) and eliminating render‑blocking scripts, LCP dropped to 1.1 seconds, and the bill fell to $1,800. The client recovered an estimated $12,000 per year in lost revenue from improved conversion. That's the kind of before‑after we regularly deliver.
Comparing tools: Next.js is 20‑30% faster in SSR builds than Nuxt with the same page size. TypeScript reduces production bugs by 60‑70% compared to JavaScript. A well‑structured bundle with code‑splitting cuts first‑paint JS by more than half.
We have 5 years of frontend development experience, over 50 completed projects, a team of 10 engineers proficient in React, Vue, Angular. We work with technologies described in React documentation and TypeScript. Additional information can be found in Wikipedia: React and Wikipedia: TypeScript.
What Stack to Choose for Frontend Development with React?
We compare tools by real metrics. Next.js is 20‑30% faster in SSR builds than Nuxt with the same page size. TypeScript reduces production bugs by 60‑70% compared to JavaScript. Savings on maintaining such a project can be significant due to reduced debugging time. If you need a lightweight SPA with minimal cost, React + Vite is enough. For a content site with SEO, Next.js with ISR gives TTFB below 50 ms even with 50,000 pages.
Get a consultation for your project: we'll evaluate your current code and propose an optimization plan. Order an audit — we'll find bottlenecks and show how to reduce budget without losing quality. Contact us to start the discussion.