How to create a sticky header in BootstrapVue table in VueJS?

Hi Friends 👋,

Welcome To SortoutCode! ❤️

To create the add the sticky header b-table in BootstrapVue.We are passing the sticky-header as a prop to create the sticky header to b-table in BootstrapVue.

Today I am going to show you How do you create a sticky header on b-table in bootstrap-vue?

Table of contains

  • Install the Bootstrap and BootstrapVue
  • Create FirstComponent.vue and import it into App.js
  • Passing sticky-header as the props in b-table

Let’s start today’s tutorial let’s check the examples of how to add a sticky header in b-table in BootstrapVue?

Install the Bootstrap and BootstrapVue

First, we have to install the Vue project, I had installed the vueJS in my system. If you haven’t installed or have any problem with installation you can follow this article, it will show you step by step process of installation. In that article, I had also show you how to install BootstrapVue in your vue.js project step by step.

How to install or configure vue-bootstrap in VueJS?

Create FirstComponent.vue and import it into App.js

Create the new component into src/components/ components folder.the component name is FirstComponent.vue and import into App.js file:


  <div id="app">
    <FirstComponent />

import FirstComponent from "./components/FirstComponent.vue";
export default {
  name: "App",
  components: {

#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;

Passing sticky-header as the props in b-table

We are going to create the sticky header in the bootstrap-vue table. Using the sticky-header prop to enable a vertically scrolling table with headers that remain fixed (sticky) as the table body scrolls. Let’s see the code:


  <div class="hello">
    <b-table sticky-header striped hover :items="items"></b-table>

export default {
  name: "FirstComponent",
  data() {
    return {
      items: [
                { id: 1, site_name: "SortoutCode", site_url: "" },
                { id: 2, site_name: "Aguidehub", site_url: "" },
                { id: 3, site_name: "Infinitbility", site_url: "" },
                { id: 4, site_name: "SortoutCode", site_url: "" },
                { id: 5, site_name: "Aguidehub", site_url: "" },
                { id: 6, site_name: "SortoutCode", site_url: "" },
                { id: 7, site_name: "Infinitbility", site_url: "" },
                { id: 8, site_name: "Test1", site_url: "" },
                { id: 9, site_name: "Test2", site_url: "" },
                { id: 10, site_name: "Test3", site_url: "" },
                { id: 11, site_name: "Test5", site_url: "" },
                { id: 12, site_name: "Test6", site_url: "" },
                { id: 13, site_name: "Test7", site_url: "" },
                { id: 14, site_name: "Test9", site_url: "" },


For now, let’s check the output.


bootstrap vue b-table sticky header

All the best 👍.

Follow me on Twitter