How to write a lot of css utility classes in-line efficiently?
13:31 15 Sep 2026

I took a look at a React project where they reuse their own custom UI components like , etc all throughout the project. At the bottom I show what such a typical UI component looks like. React is relatively new to me in the sense that I need to figure out how to properly encapsulate css styles when writing such components. My question is: is this how the developer originally wrote these lines of css utility classes? Did they just write every utility class one after another inline and ended up with such a long string of utility classes? Or did they do this differently, in a more, like, convenient way, and then they used some sort of, like, a compiler or whatever it was, any kind of tool that then transformed what was in a convenient format to write CSS with utility classes into this one-line-utility-class string in the TSX file? If that's how they initially wrote all of that, then my next question is what kind of tools would you assume they used to make it easier to do that because without any additional tools it seems to be difficult to write and keep track of all these css util classes when written in-line like that.

Here's the code (it's an open source project, I did it so github will take you to their components folder when all these components are):

"use client";

import { cva, type VariantProps } from "class-variance-authority";
import type * as React from "react";

import { cn } from "@coss/ui/lib/utils";
import { Input, type InputProps } from "@coss/ui/components/input";
import { Textarea, type TextareaProps } from "@coss/ui/components/textarea";

function InputGroup({ className, ...props }: React.ComponentProps<"div">) {
  return (
    
); } const inputGroupAddonVariants = cva( "[&_svg]:-mx-0.5 flex h-auto cursor-text select-none items-center justify-center gap-2 leading-none [&>kbd]:rounded-[calc(var(--radius)-5px)] in-[[data-slot=input-group]:has([data-slot=input-control],[data-slot=textarea-control])]:[&_svg:not([class*='size-'])]:size-4.5 sm:in-[[data-slot=input-group]:has([data-slot=input-control],[data-slot=textarea-control])]:[&_svg:not([class*='size-'])]:size-4 not-has-[button]:**:[svg:not([class*='opacity-'])]:opacity-80", { defaultVariants: { align: "inline-start", }, variants: { align: { "block-end": "order-last w-full justify-start px-[calc(--spacing(3)-1px)] pb-[calc(--spacing(3)-1px)] [.border-t]:pt-[calc(--spacing(3)-1px)] [[data-size=sm]+&]:px-[calc(--spacing(2.5)-1px)]", "block-start": "order-first w-full justify-start px-[calc(--spacing(3)-1px)] pt-[calc(--spacing(3)-1px)] [.border-b]:pb-[calc(--spacing(3)-1px)] [[data-size=sm]+&]:px-[calc(--spacing(2.5)-1px)]", "inline-end": "has-[>:last-child[data-slot=badge]]:-me-1.5 has-[>button]:-me-2 order-last pe-[calc(--spacing(3)-1px)] has-[>kbd:last-child]:me-[-0.35rem] [[data-size=sm]+&]:pe-[calc(--spacing(2.5)-1px)]", "inline-start": "has-[>:last-child[data-slot=badge]]:-ms-1.5 has-[>button]:-ms-2 order-first ps-[calc(--spacing(3)-1px)] has-[>kbd:last-child]:ms-[-0.35rem] [[data-size=sm]+&]:ps-[calc(--spacing(2.5)-1px)]", }, }, }, );
html css reactjs