BootstrapVue Table Column Align Right

Jul 17, 2020

Solution 1: custom header and cell

<b-table hover :items="items">  <template v-slot:head(price)="data">    <div class="text-right">{{ data.label }}</div>  </template>  <template v-slot:cell(price)="data">    <div class="text-right">{{ data.value }}</div>  </template></b-table>

Solution 2: via fields

<template>  <div>    <b-table hover :items="items" :fields="fields" />  </div></template><script>export default {  data() {    items: [      {        name: 'USB Cable',        price: 1.25      },      {        name: 'Pencil',        price: 0.5      },    ],    fields: [      { label: 'NAME', key: 'name'},      { label: '$', key: 'price', tdClass: 'text-right', thClass: 'text-right'}    ]  },}  </script>

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.