Published on May 14, 2021

Setting a tab other than the first one as active tab in Oxygen

Sridhar Katakam

When using the Tabs component in Oxygen, the first one will be the active tab by default.

To make a different tab say, the third one to be active on page load, the common approach is to trigger click on the tab or remove and add active classes using JavaScript. But we can use just the order CSS property and get this done.

Here’s how.

Step 1

Position the title and contents of the tab that should be highlighted on page load at the top in the structure.

third tab and its contents are moved to the top

Step 2

At Manage > Stylesheets add this CSS:

/* Change tabs order */
/* 1, 2, 3 should become 3, 1, 2 */
#_tabs-22-82 :nth-child(1) {
order: 3;
}
#_tabs-22-82 :nth-child(2) {
order: 1;
}
#_tabs-22-82 :nth-child(3) {
order: 2;
}

replace all instances of _tabs-22-82 with the ID of your Tabs component.

tagschevron-leftchevron-rightchainangle-rightangle-upangle-downfolder-omagnifiercrossmenuchevron-downarrow-right