How can we help you today?

How to Set Up Tabs to Have No Default Selection on Page Load

When your SharePoint page loads, the Tabs Design Element automatically opens a default tab:


default tabs


This article will show you how to configure the Tabs Design Element to have no default selection when your page loads:


no tabs selection


TABLE OF CONTENTS


Prerequisites


Step-by-step Tutorial

Follow the steps below to learn how to set up the Tabs Design Element to have no default selection on page load.


Step 1: Edit the ShortPoint Web Part

Go to the SharePoint page you want to use and click Edit:


Edit


Close the Toolbox:


close icon


Select the ShortPoint tag:


ShortPoint tag


Edit ShortPoint:


Edit properties icon


Step 2: Edit the Tabs Design Element


NOTEBefore proceeding, make sure you already have a Tabs Design Element on your SharePoint page. 

Tabs Design Element


Click the Tabs tag:


Tabs tag


Select the cogwheel icon:


cogwheel icon


Step 3: Add a Class Name

Click the next icon:


next icon


Go to the Custom CSS tab:


Custom CSS tab


Write tabs-no-default-selected as the Class name:


Class Name


Apply your changes:


Apply


Step 4: Insert the Code Design Element


NOTEMake sure to insert the Code Design Element below your Tabs Design Element.


Click the plus icon to open the library of Design Elements:


plus icon


Use the search bar to look for Code and select it:


Code


Step 5: Copy the Codes

Copy the codes below.

HTML Code:


<style id="tabs-no-default-selected-style">
  .tabs-not-selected-on-mobile .shortpoint-li.shortpoint-active > .shortpoint-a {      
    background-color: transparent !important;
    color: white !important;
  }

  .tabs-not-selected-on-mobile .shortpoint-tab-pane.shortpoint-active {
    display: none !important;
  }
</style>


JavaScript Code:


function onElement(selector, stopAfter, callback, root = document) {
    const start = Date.now();
    const interval = setInterval(() => {
        const element = root.querySelector(selector);
        if (element) {
            clearInterval(interval);
            callback(element);
        } else if (Date.now() - start >= stopAfter) {
            clearInterval(interval);
        }
    }, 300);
}


// Wait for at least one tab container to appear
onElement(".tabs-no-default-selected", 20000, () => {
  // Now select all tab containers
  const tabContainers = document.querySelectorAll(".tabs-no-default-selected");
  tabContainers.forEach((container) => {
    // Wait for the active tab inside each container
    onElement(
      ".sp-type-tab.shortpoint-active",
      20000,
      () => {
        // Find the active tab and pane within this container
        const tab = container.querySelector(".sp-type-tab.shortpoint-active");
        if (tab) {
          tab.classList.remove("shortpoint-active");
          tab.removeAttribute("sp-vb-active-child");
          tab.querySelector(".shortpoint-tab-title").style.removeProperty("color");
        }

        const tabPane = document.querySelector(
          ".shortpoint-tab-pane.shortpoint-active"
        );
        if (tabPane) {
          tabPane.classList.remove("shortpoint-active");
        }

        // Remove the style element if it exists
        const styleElement = document.querySelector("#tabs-no-default-selected-style");
        if (styleElement) {
          styleElement.remove();
        }
      },
      container // Use the container as the root for querySelector
    );
  });
});

Step 6: Paste Codes

Paste the codes in step 5 in their respective fields.

HTML code in the HTML field:


paste in HTML


JavaScript code in the JavaScript field:


paste in JavaScript field


Step 7: Disable Sandbox Mode

Navigate to the Design tab:


Design tab


Disable Sandbox Mode:


disable Sandbox Mode


Apply changes:


Apply


Step 8: Save

Click Save to keep your changes:


Save


That’s it! Now, when you load the page, there is no more automatic tab selection:


no tabs selection


Related articles:

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.

World's best intranet sites are designed using ShortPoint

Get started today! Learn more
See all 85 topics

Start a trial

Ignite your vision. Install ShortPoint directly on your site, or play in sandbox mode. No credit card required.

Get started today

World’s best intranet sites are designed using ShortPoint

Thousands of companies using ShortPoint everyday to design, brand and build award winning intranet sites.

Get started Learn more