Osman Goni
Osman Goni

Reputation: 153

header align center in b-modal of bootstrapVue

            <div class="text-center">
            <b-modal visible centered id="send-pin-modal" header="test" title="Confirm Approval" hide-footer hide-header-close no-close-on-backdrop no-close-on-esc>
                <div class="col-12 text-center">
                    <!--<p class="col-12">After being approved, the disbursement cannot be undone.</p>-->
                </div>
                <div class="col-12">
                    <div class="ml-5 mr-5">
                    <b-form-input  type="password" id="pin-input" v-model="pin"  required></b-form-input>
                    </div>
                </div>
                <div class="col-12 text-center">
                    <slot name="pin-error" class="text-danger text-center" v-show="comment">{{comment}}</slot>
                </div>
                <div class="col-12">
                </div>
                <div class="col-12 text-center">
                    <b-button variant="primary" size="sm" class="mt-2 mr-2" @click="verifyPin">Continue</b-button>
                    <b-button  variant="danger" size="sm" class="mt-2 ml-2" @click="hidePinModal">Cancel</b-button>
                </div>
            </b-modal>
        </div>

here is my sample code of bootstrapVue. I also attach output image.

enter image description here

How can i allight title "Confirm Approval" as center?

Upvotes: 4

Views: 5999

Answers (3)

Luca
Luca

Reputation: 348

have you tried with class="mx-auto"?
https://bootstrap-vue.org/docs/reference/spacing-classes#horizontal-centering

Upvotes: 0

Hiws
Hiws

Reputation: 10364

Alternatively to using the header slot. You can use the header-class prop, and add the justify-content-center utility class, to center the header.

new Vue({
  el: '#my-app',
  data: {
    comment: 'Some comment',
    pin: ''
  }
});
<link type="text/css" rel="stylesheet" href="https://unpkg.com/bootstrap/dist/css/bootstrap.min.css" />
<link type="text/css" rel="stylesheet" href="https://unpkg.com/[email protected]/dist/bootstrap-vue.min.css" />
<script src="https://unpkg.com/[email protected]/dist/vue.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/bootstrap-vue.min.js"></script>

<div id="my-app">
  <b-modal visible centered id="send-pin-modal" header="test" header-class="justify-content-center" title="Confirm Approval" hide-footer hide-header-close no-close-on-backdrop no-close-on-esc>
    <div class="col-12">
      <div class="ml-5 mr-5">
        <b-form-input type="password" id="pin-input" v-model="pin" required></b-form-input>
      </div>
    </div>
    <div class="col-12 text-center">
      <slot name="pin-error" class="text-danger text-center" v-show="comment">{{comment}}</slot>
    </div>
    <div class="col-12">
    </div>
    <div class="col-12 text-center">
      <b-button variant="primary" size="sm" class="mt-2 mr-2">Continue</b-button>
      <b-button variant="danger" size="sm" class="mt-2 ml-2">Cancel</b-button>
    </div>
  </b-modal>
</div>

Upvotes: 5

Emdadul Sawon
Emdadul Sawon

Reputation: 6077

You can use slot api to replace default title section with your custom header section.

new Vue({
  el: '#my-app',
  data: {
    comment: 'Some comment',
    pin: '',

  }
});
<link type="text/css" rel="stylesheet" href="https://unpkg.com/bootstrap/dist/css/bootstrap.min.css" />
<link type="text/css" rel="stylesheet" href="https://unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.min.css" />
<script src="https://unpkg.com/vue@latest/dist/vue.min.js"></script>
<script src="https://unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.min.js"></script>
<div id="my-app">
    <b-modal visible centered id="send-pin-modal" header="test" title="Confirm Approval" hide-footer hide-header-close no-close-on-backdrop no-close-on-esc>
        <template #modal-header>
         <div class="mx-auto">
          <h5>Confirm Approval</h5>
         </div>
        </template>
        
        <div class="col-12">
            <div class="ml-5 mr-5">
            <b-form-input  type="password" id="pin-input" v-model="pin"  required></b-form-input>
            </div>
        </div>
        <div class="col-12 text-center">
            <slot name="pin-error" class="text-danger text-center" v-show="comment">{{comment}}</slot>
        </div>
        <div class="col-12">
        </div>
        <div class="col-12 text-center">
            <b-button variant="primary" size="sm" class="mt-2 mr-2">Continue</b-button>
            <b-button  variant="danger" size="sm" class="mt-2 ml-2">Cancel</b-button>
        </div>
    </b-modal>
</div>

Upvotes: 6

Related Questions