DEV Community

The right way to resize Reactstrap's Modal component.

Audiophile on February 12, 2020

The Challenge You're working with reactstrap (bootstrap + react), that good old trusty css library which lets you style your views with ...
Collapse
 
tgoslee profile image
Trenisha Goslee

I literally have been struggling with this for two days! Thanks!

Collapse
 
itz_giddy profile image
Audiophile

You're welcome!

Collapse
 
jasmeet011 profile image
Jasmeet Singh

so nice , worked smoothly as butter

Just one more question, now that I increased the width

modal is no longer , centered, how to achieve that

attaching image for reference

Image description

Collapse
 
lolanator profile image
lolanator • Edited

Okay so i tried EVERYTHING to try and resize it, this example wouldn't work for me^^

I was trying to override the .modal-dialog class and nothing would work, I realised the syntax had to be the exact same as it was in my developer tools.

so i added @media (min-width: 576px) {
.modal-dialog {
max-width: fit-content;
margin: 1.75rem auto;
}
}
and this worked !!

Collapse
 
sirgalleto profile image
Sebastián Osorio

Love this post!

Collapse
 
itz_giddy profile image
Audiophile

Thank you! Glad you like it.

Collapse
 
nikosfi profile image
Nick Filippopoulos

Amazing. Nice approach on finding the solution as well!

Collapse
 
serbiaguy96 profile image
Serbiaguy96

Thanks man! Helped me a lot :)

Collapse
 
pallavikamboj123 profile image
Pallavi kamboj

HY! thanks for this amazing editorial. One question:- I want to change the font-size of the react header. I tried using contentClassName but that's not working. Please help me with this

Collapse
 
alok_ku_singh profile image
Alok Singh

Great post.

For my case, I had to set modalClassName instead of contentClassName. But, this post gave me idea where to check the expected variable.

Collapse
 
alok_ku_singh profile image
Alok Singh

If this doesn't work for someone then please check if this css item (width) is being overridden by other css. In this case you may give preference to your css item by adding !important in your css item as below:
.custom-modal-style {
width: 600px !important;
height: 802px !important;
}

Collapse
 
rutu2k profile image
Rutuja Dhokchaule

nicee

Collapse
 
harshlohia11 profile image
Harsh Lohia

This is not working if I want to decrease the width of the modal. Any fix or I am going wrong somewhere?

Collapse
 
nyanyiwast profile image
Sedrick Tha Dev

Thanks man! The best approach also,

Collapse
 
orongee22 profile image
yerina ju

Thank you! You saved me!!

Collapse
 
wimpywarlord profile image
Kshitij Dhyani

This was really helpful. Thanks