WEB TUTORIALS
PRACTICE EXAMPLES
HTML REFERENCES
CSS REFERENCES
PHP REFERENCES
Advertisements

How to disable tabs in Bootstrap

Topic: Bootstrap / SassPrev|Next

Answer: Remove data-toggle="tab" from Tabs

You can remove the attribute data-toggle="tab" from the tab's <a> element to disable a Bootstrap tab. Further you can add the class .disabled to the parent <li> element to make it look like disabled visually. Let's try out the following example and see how it works:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Disable Clicks on Bootstrap Tabs</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<script src="js/jquery-3.5.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</head>
<body>
    <ul class="nav nav-tabs">
        <li class="nav-item">
            <a href="#home" class="nav-link active" data-toggle="tab">Home</a>
        </li>
        <li class="nav-item">
            <a href="#profile" class="nav-link" data-toggle="tab">Profile</a>
        </li>
        <li class="nav-item">
            <a href="#messages" class="nav-link disabled" tabindex="-1" data-toggle="tab">Messages</a>
        </li>
    </ul>
    <div class="tab-content">
        <div id="home" class="tab-pane fade show active">
            <p>Aliquip placeat salvia cillum iphone...</p>
        </div>
        <div id="profile" class="tab-pane fade">
            <p>Vestibulum nec erat eu nulla rhoncu non neque...</p>
        </div>
        <div id="admin" class="tab-pane fade">
            <p>Sed consequat ante in rutrum convallis...</p>
        </div>
    </div>
</body>
</html>

Related FAQ

Here are some more FAQ related to this topic:

Advertisements
Bootstrap UI Design Templates

Your Feedback:

We would love to hear from you, please drop us a line.