Test365i
365i.co.uk
Back to all guides
Elementor

Style the Elementor 4 Tabs element with global classes

The Elementor 4 Tabs element is built from separate atomic parts: a menu of tab buttons and a content area of panels. This guide styles it with global classes the way the element gallery on this site does, including the two fixes it needed: a hover state you can read and a row of tabs that does not wrap.

e-tabs

Follow the steps

Numbered instructions for the Elementor editor, in the order you do them.

20 minutesCustom codeElementor

Works on WordPress 7.2, Elementor 4.4.2 and Elementor Pro 4.4.2; Elementor's Tabs help article does not say Pro is needed

Editorial integrity: read our editorial standards.

  1. Add the Tabs element and learn its parts

    Drag in the Tabs element. In the Navigator it shows two branches: a Tabs menu holding one Tab per button, and a Tabs content area holding one Tab content per panel. They are paired by position, so the second tab opens the second panel. Elementor adds the accessibility attributes itself; the markup below is a simplified copy of what it printed on the Elementor 4 element gallery page, with my class names added.

    Three tabs in a tablist each paired by position with a panel, the first visible and the others hidden
    Each tab controls the panel in the same position.
    elementor-output.htmlHTML
    <div class="e-tabs">
    	<div class="e-tabs-menu" role="tablist">
    		<button class="e-tab pill-tab" role="tab" aria-selected="true" aria-controls="panel-1">Steps</button>
    		<button class="e-tab pill-tab" role="tab" aria-selected="false" aria-controls="panel-2">Code</button>
    		<button class="e-tab pill-tab" role="tab" aria-selected="false" aria-controls="panel-3">Demo</button>
    	</div>
    	<div class="e-tabs-content-area">
    		<div class="e-tab-content tabs-panel" role="tabpanel" id="panel-1">Follow the steps</div>
    		<div class="e-tab-content tabs-panel" role="tabpanel" id="panel-2" hidden>Copy the code</div>
    		<div class="e-tab-content tabs-panel" role="tabpanel" id="panel-3" hidden>Watch it run</div>
    	</div>
    </div>

    The W3C's ARIA Authoring Practices describe the relationship Elementor builds for you:

    Each tab panel has an associated tab element, that when activated, displays the panel.

    W3C ARIA Authoring Practices Guide, Tabs Pattern

    That association is the aria-controls and aria-labelledby pair Elementor prints on each tab and panel. Because the link is made by position, deleting a tab without its panel breaks it, so add and remove them together in the Navigator.

  2. Give the tab buttons a class

    Select each Tab and add the class pill-tab (in Elementor 4 the class is shared, so styling one styles all three). The selected tab is marked with aria-selected="true", which makes a better selector than a state class: it is exactly what screen readers announce.

    tabs.cssCSS
    .pill-tab {
    	padding: 10px 16px;
    	border-radius: 999px;
    	border: 1px solid #66667D;
    	background-color: rgba(255, 255, 255, 0.05);
    	color: #BBBBD1;
    	font: 500 14px/1 system-ui, sans-serif;
    	cursor: pointer;
    }
    
    .pill-tab[aria-selected="true"] {
    	background-color: #F6F6FC;
    	border-color: #F6F6FC;
    	color: #080813;
    }
    After step 2: pill tabs. Point at Code: Elementor's built-in hover turns it pale grey, and the text nearly vanishes.
  3. Fix the hover so it stays readable

    Elementor 4 gives its tab base a light grey hover (#E0E0E0). On this site the tab class turned the text white on hover, and white on light grey is close to invisible: it was reported to me from the live site with a screenshot of exactly that. The fix is a hover rule with enough specificity to beat Elementor's default, which .elementor button.pill-tab has, plus a rule that keeps the selected tab white.

    tabs.cssCSS
    .elementor button.pill-tab:hover,
    .elementor button.pill-tab:focus-visible {
    	background-color: rgba(255, 255, 255, 0.1);
    	border-color: rgba(255, 255, 255, 0.28);
    	color: #F6F6FC;
    }
    
    .elementor button.pill-tab[aria-selected="true"]:hover {
    	background-color: #F6F6FC;
    	color: #080813;
    }
    After step 3: hovering Code gives a dark glass pill with white text.
  4. Keep the tabs on one row

    Give the Tabs menu the class tabs-menu. With wrapping allowed, the third tab dropped onto a second row in the element gallery. flex-wrap: nowrap plus flex: 1 1 0 on each tab shares the width equally, so they fit at desktop and phone widths.

    tabs.cssCSS
    .tabs-menu {
    	display: flex;
    	gap: 8px;
    	flex-wrap: nowrap;
    }
    
    .pill-tab {
    	flex: 1 1 0;
    	min-width: 0;
    }
    After step 4: the three tabs share the row and no longer wrap, even in a narrow column.
  5. Style the panels

    Give each Tab content the class tabs-panel for a soft glass card. The panels sit in the content area one at a time, so they can share one style. The tabs at the top of this guide are the real Elementor 4 element, styled the same way with this site's classes, so you can click them to switch. They also run in the element gallery. Compare the Elementor 4 accordion, which shows more than one item at once.

    tabs.cssCSS
    .tabs-panel {
    	padding: 24px;
    	border-radius: 16px;
    	border: 1px solid rgba(255, 255, 255, 0.12);
    	background-color: rgba(255, 255, 255, 0.05);
    	color: #BBBBD1;
    }
    After step 5: the selected panel is a soft glass card under the tabs.

    Heydon Pickering, writing about tab interfaces on Inclusive Components, adds a caution worth keeping:

    Just because you can doesn't mean you should.

    Heydon Pickering, Inclusive Components, "Tabbed Interfaces"

    Tabs hide content, so they suit a few short, parallel views of one subject, like the three in the demo. For long content that people read in order, headings on a page work better, which is why the guides on this site use numbered steps rather than tabs.

What the Elementor 4 Tabs element does not do here

It does not remember the open tab when the page reloads.

Hidden panels are still in the page, but people only see the selected one. Do not put content in a later tab that every visitor must read.

Elementor's help article for the Tabs element does not say whether it needs Pro, and this site runs Elementor Pro, so I have not confirmed it on free Elementor.

All the CSS for these tabs

Each file below is complete. Copy it, or download it under the name shown.

elementor-output.htmlHTML
<div class="e-tabs">
	<div class="e-tabs-menu" role="tablist">
		<button class="e-tab pill-tab" role="tab" aria-selected="true" aria-controls="panel-1">Steps</button>
		<button class="e-tab pill-tab" role="tab" aria-selected="false" aria-controls="panel-2">Code</button>
		<button class="e-tab pill-tab" role="tab" aria-selected="false" aria-controls="panel-3">Demo</button>
	</div>
	<div class="e-tabs-content-area">
		<div class="e-tab-content tabs-panel" role="tabpanel" id="panel-1">Follow the steps</div>
		<div class="e-tab-content tabs-panel" role="tabpanel" id="panel-2" hidden>Copy the code</div>
		<div class="e-tab-content tabs-panel" role="tabpanel" id="panel-3" hidden>Watch it run</div>
	</div>
</div>
tabs.cssCSS
.pill-tab {
	padding: 10px 16px;
	border-radius: 999px;
	border: 1px solid #66667D;
	background-color: rgba(255, 255, 255, 0.05);
	color: #BBBBD1;
	font: 500 14px/1 system-ui, sans-serif;
	cursor: pointer;
}

.pill-tab[aria-selected="true"] {
	background-color: #F6F6FC;
	border-color: #F6F6FC;
	color: #080813;
}

.elementor button.pill-tab:hover,
.elementor button.pill-tab:focus-visible {
	background-color: rgba(255, 255, 255, 0.1);
	border-color: rgba(255, 255, 255, 0.28);
	color: #F6F6FC;
}

.elementor button.pill-tab[aria-selected="true"]:hover {
	background-color: #F6F6FC;
	color: #080813;
}

.tabs-menu {
	display: flex;
	gap: 8px;
	flex-wrap: nowrap;
}

.pill-tab {
	flex: 1 1 0;
	min-width: 0;
}

.tabs-panel {
	padding: 24px;
	border-radius: 16px;
	border: 1px solid rgba(255, 255, 255, 0.12);
	background-color: rgba(255, 255, 255, 0.05);
	color: #BBBBD1;
}

Elementor 4 tabs questions

How are tabs and panels linked in Elementor 4?

By position. The first tab opens the first panel, so add and remove them in pairs in the Navigator.

Why are my Elementor tabs unreadable on hover?

Elementor's built-in hover is light grey. If your tab text is white, add a hover rule with more specificity, as in step 3.

Why do my tabs wrap onto two lines?

The menu allows wrapping. Set flex-wrap: nowrap on the menu and flex: 1 1 0 on each tab.

Are Elementor 4 tabs accessible?

Elementor prints the tablist, tab and tabpanel roles and links each tab to its panel, which is the pattern the W3C describes.

Can I style the selected tab differently?

Yes. Target [aria-selected="true"] on the tab, which matches what assistive technology announces.

Where does the CSS go?

The plain styles can live in the classes in the Elementor 4 style panel. The hover override in step 3 needed a Custom Code snippet on this site to beat Elementor's default.

Can I add a glow to the selected tab?

Yes. A soft box-shadow works well. Box Shadow Generator, made by Mark McNeece of 365i, builds one you can copy.

Sources

  1. W3C ARIA Authoring Practices Guide: Tabs Pattern
  2. Heydon Pickering, Inclusive Components: Tabbed Interfaces
  3. Elementor: Tabs Element (Editor V4)

More build guides

The latest guides, newest first.

Elementor

A clickable card grid with the Elementor 4 Collection loop

The Elementor 4 Collection loop repeats one design for every post a query finds. On this site it lists the build guides, which are a JetEngine post type, in the element gallery, the Lab and the mega menu, all from one card component. This guide builds that grid, makes each whole card clickable and hides fields that come back empty.

25 minutes Get the guide
Elementor

Style the Elementor 4 Carousel element: arrows, dots and loop

The Elementor 4 Carousel element gives you slides, arrows and dots as separate atomic parts. Out of the box on this site, the arrows sat on top of the slide titles, the active dot was black on a dark panel and Loop did nothing. This guide fixes all three, with the CSS the element gallery now runs.

20 minutes Get the guide
Elementor

The Elementor 4 Accordion element, built on native details

The Elementor 4 Accordion element is built on the browser's own details and summary elements, so it opens and closes with no script. This guide sets it up the way the element gallery on this site does, styles it with classes, and explains the FAQ schema switch and what Google now does with it.

15 minutes Get the guide