How to Learn Tailwind CSS with a Live Playground
Learn Tailwind CSS v4 by experiment: utility classes, responsive and state variants, theme variables, converting existing CSS and keeping classes tidy.

How to Learn Tailwind CSS with a Live Playground
Tailwind CSS takes a different approach to styling. Instead of writing a .card class in a stylesheet and naming every variation, you compose small single-purpose classes in the HTML: p-6 rounded-xl bg-white shadow-lg. People are often sceptical until they try it, and then the speed of building and changing layouts wins them over. The best way to learn is to experiment with instant feedback, which is what the Tailwind CSS Playground and Class Builder is for.
The core idea
Each utility does one thing. p-4 sets padding, flex makes a flex container, text-slate-700 sets text colour, md:grid-cols-3 sets three columns from the medium breakpoint up. Because the classes are generated from a design scale, spacing and colours stay consistent without anyone policing them. The build step scans your files and generates only the CSS for classes you use, so the final stylesheet stays small.
The spacing and size scale
Spacing utilities follow a 4-pixel step: 1 is 4 px, 4 is 16 px, 6 is 24 px. The same numbers work for padding, margin, gap, width and height. When you need something off the scale, arbitrary values in square brackets, such as p-[13px] or bg-[#1d4ed8], are allowed, but frequent arbitrary values suggest your design scale needs a new step.
Responsive design, mobile first
Unprefixed classes apply at every width. Prefixes add rules from a breakpoint upwards: sm at 640 px, md at 768 px, lg at 1024 px, xl at 1280 px and 2xl at 1536 px. So flex-col md:flex-row stacks items on phones and places them side by side on tablets and up. Testing at a phone width, a tablet width and a desktop width catches most layout problems early.
State variants
hover:, focus:, active:, disabled: and others apply styles in a state: hover:bg-blue-700 darkens a button on hover, focus:ring-2 shows a focus ring for keyboard users. Do not remove focus styles without replacing them; visible focus is an accessibility requirement. Dark mode uses the dark: variant, driven by the user's system setting or by a class on the root element.
Theme variables in version 4
Tailwind v4 moved configuration into CSS. An @theme block defines design tokens as variables: --color-brand: #0ea5e9 creates bg-brand, text-brand and border-brand, and --font-display creates font-display. This keeps your brand values in one place and makes them available as normal CSS variables too.
Converting existing CSS
Migrating a project usually starts with existing rules. Many properties map directly: padding: 24px becomes p-6, border-radius: 12px becomes rounded-xl, display: flex becomes flex, a :hover rule becomes hover: classes, and a min-width media query becomes an md: or lg: prefix. Values outside the scale become arbitrary values, and properties without a utility can be written as arbitrary properties like [mix-blend-mode:multiply]. Review converted output, because automatic conversion cannot know your design intent.
Keeping class lists readable
Long class strings are Tailwind's main criticism. A few habits help: keep a consistent order (layout, size, spacing, typography, colour, effects, state), avoid duplicates and conflicting pairs such as p-4 and p-6 on one element, and extract repeated patterns into components in your framework rather than copying them. The official Prettier plugin sorts classes automatically in real projects.
From playground to production
The browser build used in a playground compiles classes on the fly, which is ideal for experiments and prototypes but not for live sites. In production, use the Tailwind CLI, the Vite plugin or the PostCSS plugin, which generate a static, minimal stylesheet at build time.
Limits
A playground shows how classes render but is not a production build: the browser build adds work at page load and should not be shipped to users. Automatic CSS conversion covers common properties and the default scale only, and the result should be reviewed against your own theme and design decisions.



