I'm wondering what is the easiest way to build this kind of sidebar with Bootstrap 4.
To me, it looks like a custom component they built for the docs page, not being included in the framework. I'm not sure if I'm right.
<ul class="nav bd-sidenav">
<li class="active bd-sidenav-active">
<a href="/docs/4.0/getting-started/introduction/">
Introduction
</a>
</li>
<li>
<a href="/docs/4.0/getting-started/download/">
Download
</a>
</li>
...
</ul>
The closest I got was by creating something like this:
<ul class="nav">
<li class="w-100">
<a href="#">
Item 1
</a>
</li>
...
</ul>
But I think there should be a better way.
What is the right way to build such a sidebar/table of contents with Bootstrap 4?
Navs: It is used to create a basic and simple navigation menu with a . nav base class.
Twitter Bootstrap is a front end framework to develop web apps and sites fast. In modern web development, there are several components which are required in almost all web projects. Bootstrap provides you with all those basic modules - Grid, Typography, Tables, Forms, Buttons, and Responsiveness.
Written in TypeScript with 100% test coverage, NG-Bootstrap is a UI component library built for the job.
Here's a simple nav sidebar with content at the right:
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">
<div class="container-fluid">
<div class="row">
<div class="col-3">
<nav class="nav flex-column">
<a class="p-1 nav-link active" href="#">Active</a>
<a class="p-1 nav-link" href="#">Link</a>
<a class="p-1 nav-link" href="#">Link</a>
<a class="p-1 nav-link disabled" href="#">Disabled</a>
</nav>
</div>
<div class="col bg-light">
Here's your content! Added class bg-light for a light gray background.
</div>
</div>
</div>
(3/12)
of the screen and the content using the rest of the screen.If you want the nav to stack on smaller screens, you can replace col-3
with col-sm-3
for example. In this case the nav will stack under the sm
breakpoint.
You can read more about vertical navs here, and the grid system here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With