CSS Modules Website Markup

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.
Development and maintenance of all types of websites:
Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Our competencies:
Development stages
Latest works
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    822
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    847
  • image_website-sbh_0.png
    Website development for SBH Partners
    999
  • image_website-_0.png
    Website development for Red Pear
    451

Website markup using CSS Modules

CSS Modules solve one specific problem — global CSS namespace. In any project with more than three developers or more than a hundred components, class names start conflicting and overriding each other, and !important spreads through the codebase. CSS Modules provide local scope at build time — without runtime overhead, without shadow DOM.

How it works

Vite, Webpack, Parcel, and other bundlers transform CSS Modules at build time. Class name in .module.css file is hashed:

.button → .button_a3f7k2x
.title  → .title_9cxm1pq

Final HTML contains hashed names, conflict is impossible by definition.

/* Button.module.css */
.root {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background-color: var(--color-accent);
  color: #fff;
  border-radius: 0.5rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: background-color 150ms ease;
}

.root:hover {
  background-color: var(--color-accent-hover);
}

.root:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Variants */
.ghost {
  background-color: transparent;
  color: var(--color-accent);
  border: 1px solid var(--color-accent);
}

/* Sizes */
.sm {
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
}

.lg {
  padding: 0.75rem 1.5rem;
  font-size: 1.125rem;
}
// Button.tsx
import { FC, ButtonHTMLAttributes } from 'react';
import styles from './Button.module.css';
import clsx from 'clsx';

interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
  variant?: 'default' | 'ghost';
  size?: 'sm' | 'md' | 'lg';
}

const Button: FC<ButtonProps> = ({
  variant = 'default',
  size = 'md',
  className,
  children,
  ...props
}) => {
  return (
    <button
      className={clsx(
        styles.root,
        variant === 'ghost' && styles.ghost,
        size === 'sm' && styles.sm,
        size === 'lg' && styles.lg,
        className
      )}
      {...props}
    >
      {children}
    </button>
  );
};

Setup in Vite

CSS Modules work out of the box — any file *.module.css is processed automatically:

// vite.config.ts
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

export default defineConfig({
  plugins: [react()],
  css: {
    modules: {
      // camelCase for JS access: styles.myClass instead of styles['my-class']
      localsConvention: 'camelCase',
      // Format of generated class names
      generateScopedName:
        process.env.NODE_ENV === 'production'
          ? '[hash:base64:8]'
          : '[name]__[local]__[hash:base64:4]',
    },
  },
});

Pattern: composes for reuse

CSS Modules support composes — style inheritance without JavaScript:

/* base.module.css */
.flexCenter {
  display: flex;
  align-items: center;
  justify-content: center;
}

.card {
  background: var(--color-bg-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}
/* Hero.module.css */
.container {
  composes: flexCenter from './base.module.css';
  padding: 3rem 1rem;
  min-height: 100vh;
}

.title {
  composes: card from './base.module.css';
  font-size: 2.5rem;
  font-weight: bold;
}

Advantages

  • Zero runtime cost — compiled away at build time
  • Local scope — no BEM or naming conventions needed
  • Dead code elimination — unused styles removed in production
  • Dynamic theming — combine with CSS Custom Properties

Timeline

Integrating CSS Modules into existing project: 2–3 days. New project with full component library: included in component development timeline.