Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What component is used in the Twitter Bootstrap's docs for sidebar?

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?

like image 268
Ionică Bizău Avatar asked Nov 13 '17 16:11

Ionică Bizău


People also ask

Which Bootstrap component is used to show the users location on the website?

Navs: It is used to create a basic and simple navigation menu with a . nav base class.

What is twitter bootstrap used for?

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.

Is Bootstrap a component library?

Written in TypeScript with 100% test coverage, NG-Bootstrap is a UI component library built for the job.


1 Answers

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>

Basically we're making a grid with the nav taking 1/4th (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.

like image 83
Klooven Avatar answered Oct 28 '22 06:10

Klooven