[Vuejs]-Change hamburger icon color in Vue Bootstrap

1๐Ÿ‘

โœ…

You can use this CSS to change the color of the toggler.
You can change the stroke on the <path> to the colour you want.

If you are using a scoped style tag in your vue component (<style scoped>), then you might need to use a deep selector to properly target the toggle icon.

.navbar-toggler-icon {
   background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'><path stroke='rgba(255, 255, 255, 1)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/></svg>") !important;
}

I found this specific CSS on the Bootstrap github here

new Vue({
  el: '#app',
  data() {
    return {
      fields: [
        // A column that needs custom formatting
        { key: 'name', label: 'Full Name' },
        { key: 'age', label: 'Age' },
        { key: 'sex', label: 'Sex' }
      ],
      items: [
        { name: { first: 'John', last: 'Doe' }, sex: 'Male', age: 42 },
        { name: { first: 'Jane', last: 'Doe' }, sex: 'Female', age: 36 },
        { name: { first: 'Rubin', last: 'Kincade' }, sex: 'Male', age: 73 },
        { name: { first: 'Shirley', last: 'Partridge' }, sex: 'Female', age: 62 }
      ]
    }
  }
})
.navbar-toggler-icon {
   background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'><path stroke='rgba(255, 255, 255, 1)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/></svg>") !important;
}
<link href="https://unpkg.com/bootstrap@4.4.1/dist/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://unpkg.com/bootstrap-vue@2.12.0/dist/bootstrap-vue.css" rel="stylesheet"/>

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.11/vue.js"></script>
<script src="https://unpkg.com/bootstrap-vue@2.12.0/dist/bootstrap-vue.js"></script>

<div id="app">
  <b-navbar toggleable="xl" type="dark" variant="info">
    <b-navbar-brand href="#">NavBar</b-navbar-brand>

    <b-navbar-toggle target="nav-collapse"></b-navbar-toggle>

    <b-collapse id="nav-collapse" is-nav>
      <b-navbar-nav>
        <b-nav-item href="#">Link</b-nav-item>
      </b-navbar-nav>
    </b-collapse>
  </b-navbar>
</div>

-1๐Ÿ‘

You can also use the default color options from the documentation.
When you set the type to dark or light it will display a white or black icon.

Reference: Vue-Bootstrap Navbar: https://bootstrap-vue.org/docs/components/navbar

Leave a comment