Essential Tailwind CSS Classes to Make Your Hyvä Theme Better Without Major Customisation

Essential Tailwind CSS Classes to Make Your Hyvä Theme Better Without Major Customisation

Hyvä comes with the full Tailwind CSS library ready to use. Most merchants and developers use maybe 20% of what's available sticking to colours and basic padding. But Tailwind's real power is in the classes that handle layout, typography, interactivity, and visual polish all the things that separate a good-looking store from a great one.

Every class in this guide works in your existing Hyvä templates right now. No tailwind.config.js changes. No new build commands. Just open a .phtml file and start adding classes.

0
config file changes needed for any class in this guide
6
categories of essential utility classes covered
50+
individual utility classes with real Hyvä use cases
combinations one class often unlocks five improvements

The Six Essential Class Categories

These six areas cover the vast majority of visual improvements you can make to a stock Hyvä store with zero customisation work. Each one targets a real pain point merchants notice unclear hierarchy, cramped layouts, flat buttons, poor mobile spacing.

Layout

Flexbox & Grid Classes

Control how elements sit next to each other rows, columns, gaps, alignment. The backbone of every Hyvä template.

flexgridgap-4items-center
Typography

Text Size & Weight Classes

Instant visual hierarchy headlines feel like headlines, body copy feels readable, prices feel prominent.

text-xlfont-boldleading-snugtracking-tight
Spacing

Padding & Margin Classes

Consistent breathing room between elements. The single biggest impact on how "premium" a store feels.

p-4px-6mt-2space-y-3
Borders & Radius

Shape & Boundary Classes

Rounded corners, subtle dividers, and ring outlines that make inputs and cards look intentional, not default.

rounded-xlborderring-2divide-y
Transitions

Hover & Motion Classes

Smooth hover states, colour fades, scale effects the microinteractions that make a store feel alive.

transitionhover:scale-105duration-200
Colour & Shadow

Depth & Colour Classes

Backgrounds, shadows, text colours, and opacity the visual depth layer that separates cards and sections.

shadow-mdbg-whitetext-gray-900opacity-75

Category 1 Layout: Flexbox & Grid

The most common issue in stock Hyvä stores is elements stacking vertically when they should sit side-by-side, or grids that don't respond properly to different screen sizes. These classes fix that immediately.

1

Product Card Grid Responsive Columns

grid · grid-cols-* · gap-* no config needed

The default Hyvä product listing uses a basic grid. Add responsive column classes directly to the wrapper div in Magento_Catalog/templates/product/list.phtml and the grid instantly adapts from 1 column on mobile to 4 on desktop.

Before / After · Product List Template
❌ Before
<div class="product-items">
✓ After
<div class="grid grid-cols-2 gap-4 sm:grid-cols-3 lg:grid-cols-4">
grid grid-cols-2 gap-4 / gap-6 sm:grid-cols-3 lg:grid-cols-4
2

Header / Navbar Space Between

flex · items-center · justify-between · gap-*

Hyvä's header templates already use flex in places, but inner rows often lack proper vertical alignment and gap control. Adding items-center and gap-4 to a nav row instantly fixes elements that feel "off" vertically.

Magento_Theme/templates/html/header.phtml PHTML
<!-- Nav row: logo + search + icons perfectly aligned -->
<div class="flex items-center justify-between gap-4 py-3 px-4">
    <!-- Logo -->
    <a href="/" class="flex-shrink-0">...</a>
    <!-- Search -->
    <div class="flex-1 max-w-lg">...</div>
    <!-- Icons -->
    <div class="flex items-center gap-3 flex-shrink-0">...</div>
</div>
          
flex items-center justify-between flex-1 flex-shrink-0 max-w-lg

Category 2 Typography: Instant Hierarchy

Typography is where most Hyvä stores feel generic. The default size scale is functional but flat everything looks roughly the same weight. These classes add proper hierarchy in seconds.

Class What it does Best used on
text-2xl font-bold Large, bold text strong visual anchor Product name, page title, price
text-sm text-gray-500 Small muted text deprioritises secondary info SKU, meta info, review count
leading-snug Tighter line height makes multi-line names feel compact Product card titles (2-line clamp)
tracking-tight Tighter letter spacing makes headings feel more typeset H1, H2, section headings
line-clamp-2 Truncates text to exactly 2 lines with ellipsis Product card names in grid listings
truncate Single-line truncation with ellipsis Category names, breadcrumb items
uppercase tracking-widest text-xs Spaced small-caps label style Section labels, status badges, tags
font-semibold text-primary Medium-weight coloured text emphasis without full bold Price, CTA labels, links
Product card name + price before & after PHTML
<!-- ❌ Before: flat, no hierarchy -->
<p class="product-name"><?= $product->getName() ?></p>
<p class="price"><?= $block->getProductPrice($product) ?></p>

<!-- ✓ After: clear hierarchy, clean truncation -->
<h3 class="text-sm font-semibold text-gray-900 leading-snug line-clamp-2 mb-1">
    <?= $escaper->escapeHtml($product->getName()) ?>
</h3>
<p class="text-base font-bold text-primary">
    <?= $block->getProductPrice($product) ?>
</p>
      

Category 3 Spacing: The Premium Factor

No single change makes a store look more "premium" than consistent, generous spacing. Cramped elements signal low quality. These classes are the fastest ROI in this entire guide.

3

space-y-* Stack Children Consistently

Replace manual margin-bottom on every child with one class on the parent

Instead of adding mb-3 to every list item or card child, add space-y-3 to the parent container. It applies consistent vertical spacing between all direct children automatically and it's trivial to adjust globally later.

Before / After · Sidebar filter list
❌ Before margin on every item
<ul>
  <li class="mb-2">...</li>
  <li class="mb-2">...</li>
  <li class="mb-2">...</li>
</ul>
✓ After one class on parent
<ul class="space-y-2">
  <li>...</li>
  <li>...</li>
  <li>...</li>
</ul>
space-y-2 space-y-3 space-y-4 space-x-3 gap-6
Spacing scale to remember: Tailwind's spacing scale is in 4px increments p-1 = 4px, p-2 = 8px, p-4 = 16px, p-6 = 24px, p-8 = 32px. Once this is instinct, you'll space everything consistently without thinking.

Category 4 Borders & Radius: Make Cards Feel Intentional

Default Hyvä product cards often have either square corners (feels like a spreadsheet) or inconsistent border radii across elements. A single rounded-xl and a light border border-gray-100 transforms the visual quality of every card on the page.

Radius

rounded-* Classes

Apply border radius to any element. Use rounded-xl for cards, rounded-lg for buttons, rounded-full for badges and avatars.

rounded-lgrounded-xlrounded-2xlrounded-full
Border

border + border-color

Light borders make cards visible without heavy shadows. border border-gray-100 is the most-used combination in Hyvä stores.

borderborder-gray-100border-gray-200
Divide

divide-y / divide-x

Automatically adds a border between all direct children perfect for nav lists, order line items, or filter option rows.

divide-ydivide-gray-100divide-x
Ring

ring-* Focus States

Accessible focus rings for inputs, buttons, and links much better than browser defaults. Works perfectly with Alpine x-bind:class.

focus:ring-2focus:ring-primaryfocus:outline-none

Category 5 Transitions & Hover States

This is the category that makes the biggest perceived quality difference with the least code. A product card that subtly lifts on hover, a button that smoothly changes colour, an image that gently zooms these microinteractions signal that a store is well-made.

4

Product Card Hover Lift

transition · hover:shadow-md · hover:-translate-y-1 · duration-200

Add this single class string to any product card wrapper and it gains a smooth lift-and-shadow effect on hover the visual equivalent of a card being picked up off the table.

Product card wrapper PHTML
<div class="bg-white rounded-xl border border-gray-100
              shadow-sm hover:shadow-md hover:-translate-y-1
              transition-all duration-200 overflow-hidden">
    <!-- card content -->
</div>
          
transition-all duration-200 hover:shadow-md hover:-translate-y-1
5

Button Hover States

hover:bg-* · active:scale-95 · transition-colors · cursor-pointer

Stock Hyvä buttons often have no hover feedback at all they just sit there, flat. Adding hover:bg-teal-700 transition-colors duration-150 and the subtle click-press effect active:scale-95 gives buttons proper interactive feedback.

Add to Cart button PHTML
<button
    class="w-full py-3 px-6 rounded-lg font-semibold text-sm text-white
           bg-primary hover:bg-teal-700 active:scale-95
           transition-all duration-150 cursor-pointer
           focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2">
    Add to Cart
</button>
          
hover:bg-teal-700 active:scale-95 transition-all focus:ring-2 focus:ring-offset-2

Category 6 Colour & Shadow: Visual Depth

Flat stores look flat because every section has the same background and every card has the same weight. These classes add depth subtle backgrounds that section content, shadows that layer elements, and colour utilities that reinforce hierarchy.

Class Effect Use in Hyvä
shadow-sm Barely-visible shadow "floating" card effect Product cards, mini-cart, dropdown panels
shadow-md Moderate shadow used on hover state for lift effect hover:shadow-md on cards
bg-gray-50 Near-white background visually separates sections Category page background, sidebar panels
bg-white Pure white card sits above the page background All product cards, checkout panels
text-gray-500 Muted text secondary information that doesn't compete Review counts, meta, helper text
bg-primary/10 10% opacity tint of your brand colour subtle highlight Active filter pills, selected states, badges
overflow-hidden Clips child content to parent border radius critical for image cards Always pair with rounded-xl on image containers

Bonus: Mobile-First Responsive Classes You Should Always Use

In Tailwind, every unprefixed class is the mobile baseline. Responsive prefixes (sm: md: lg:) add behaviour at that breakpoint and above. Here are the responsive patterns used most in Hyvä stores:

Common responsive patterns in Hyvä .phtml templates PHTML
<!-- Stack on mobile, side-by-side from md up -->
<div class="flex flex-col md:flex-row gap-6">...</div>

<!-- Wider padding on larger screens -->
<div class="px-4 sm:px-6 lg:px-8">...</div>

<!-- Hide on mobile, show from md -->
<div class="hidden md:block">...</div>

<!-- Show only on mobile -->
<div class="block md:hidden">...</div>

<!-- Responsive text size -->
<h1 class="text-2xl sm:text-3xl lg:text-4xl font-bold tracking-tight">
    <?= $escaper->escapeHtml($block->getPageTitle()) ?>
</h1>

<!-- Responsive grid 1 col mobile, 2 tablet, 4 desktop -->
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">...</div>
      
The difference between a store that looks like a template and one that looks considered comes down to three things: consistent spacing, proper typography hierarchy, and hover feedback. All of it is available in Tailwind the classes are already in your Hyvä build, waiting to be used.

The Quick-Reference Cheat Sheet

Pin this. These are the classes that appear in almost every high-quality Hyvä template:

Layout

Every Layout File Needs

flexitems-centergap-4 gridgrid-cols-2flex-1 w-fullmax-w-7xlmx-auto
Typography

Every Product Card Needs

text-smfont-semiboldtext-gray-900 line-clamp-2leading-snugtruncate text-basefont-bold
Spacing

Every Card/Panel Needs

p-4px-4 py-3space-y-2 gap-3mb-1mt-auto
Shape

Every Card/Button Needs

rounded-xlrounded-lgoverflow-hidden borderborder-gray-100
Interaction

Every Interactive Element Needs

transition-allduration-200cursor-pointer hover:shadow-mdhover:-translate-y-1active:scale-95
Depth

Every Page Section Needs

bg-whitebg-gray-50shadow-sm text-gray-500text-gray-900
i
Remember the safelist: If you're building class names dynamically in PHP (e.g. reading a colour from a CMS attribute), add those class patterns to the safelist in tailwind.config.js otherwise they'll be purged from the production build and disappear silently.

Final Thoughts

You don't need a design agency or a major rebuild to make your Hyvä store look significantly better. The classes in this guide are available right now in your existing theme, and most improvements take under five minutes to apply.

Start with the highest-impact areas: product card layout, typography hierarchy on names and prices, hover states on buttons and cards, and consistent spacing via space-y-* and gap-*. Those four changes alone will transform how your store feels to shoppers.

Once you're comfortable with these, the next step is building reusable component classes with @apply which removes repetitive class strings from your templates and makes global style changes trivial. That's where the real long-term efficiency lives.

Want it done for you?

Let Mavenbird Improve Your Hyvä Store's Frontend

From quick-win template improvements to full Hyvä design systems our certified Hyvä developers know exactly which classes, patterns, and component architectures deliver the best results for Magento merchants.

Hyvä Child Theme Setup
Tailwind Design System
Template Improvements
Component Library
Performance Audit
Luma → Hyvä Migration


Loading...

Talk to an Expert

Request a Free Quote and expert consultation.