question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[modal] option to set a width

See original GitHub issue

This is an enhancement request.

There is size option (i.e. sm, md) for the modal component, but it would be great if there is an option to set the exact width / max-width. For example, <b-modal :width=400></b-modal> so that the modal width would not be no more than 400px.

Thank you.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

19reactions
tmorehousecommented, Jul 4, 2017

Bootstrap-vue tries to follow the Bootstrap V4 standard CSS, and hence we only offer the standard Bootstrap modal sizes.

You can, however, place a class on <b-modal>, which will get applied to modal’s root element (div.modal), and then target the .modal-dialog to set the width

HTML:

<b-modal class="my-modal" ...>
   Modal Content
</b-modal>

CSS:

div.modal.my-modal .modal-dialog {
  width: 400px; !important;
}

This technique will also allow you to set the width based on media queries as well, so it will fit on mobile devices.

18reactions
tmorehousecommented, Nov 26, 2018

@Ota-kun , @vacolane

Create a new modal-[size] class like modal-huge, and then create custom CSS to set width (note Bootstrap V4 uses max-width on all modal sizes, so you need to set max-width, and based on media queries, so you may need to target a certain screen width)

.modal .modal-huge {
  max-width: 2000px;
  width: 2000px;
}

and use that size on b-modal:

<b-modal size="huge" ... >
</b-modal>

The size prop just adds a class on the modal-dialog element modal-xxx where xxx is the text passed to the size prop (i.e. huge is converted to modal-huge). So modal isn’t limiting you to specific sizes, it is only limited by what CSS classes exist.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to increase Bootstrap Modal Width? - Stack Overflow
You can choose between modal-lg and modal-xl classes or if you want custom width then, set max-width property with inline css. For example,...
Read more >
How to Change the Default Width of Bootstrap Modal Box
Answer: Set width for .modal-dialog element ... By default, Bootstrap modal are available in four different sizes — small, default, large and extra-large....
Read more >
How to change Bootstrap Modal Width and Height - 3 Examples
In order to increase or decrease the modal window height and width properties of Bootstrap, you need to get the modal related classes...
Read more >
How to configure modal width in Bootstrap? - GeeksforGeeks
In this article, we will focus on adjusting the width/height of the modal box. Method 1: Using pre-defined Bootstrap classes
Read more >
Modal - Bootstrap
Use Bootstrap's JavaScript modal plugin to add dialogs to your site for lightboxes, user notifications, or completely custom content.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found