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.

Custom Background Colour for Modal Display

See original GitHub issue

Currently the background of Modal component is set to either transparent or white. User should have control over the background. I’m Referring to issue #12478

Environment

OS: macOS High Sierra 10.13.3 Node: 9.7.1 Yarn: Not Found npm: 5.6.0 Watchman: Not Found Xcode: Not Found Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)

react: ^16.2.0 => 16.2.0 react-native: ^0.53.0 => 0.53.0

Expected Behavior

Expected default behaviour of Modals on mobile devices, is that on display of the modal, the background page dims. Currently, the transparent property of the Modal component sets the background to either transparent or white. It would make more sense to give the user the ability to set custom background colour (e.g: rgba(0, 0, 0, 0.4) for dim background)

Actual Behavior

Currently the background for Modal component is either transparent or white

Solution

I was able to change the code (in Libraries/Modal/Modal.js) that when transparent is false, it dims the background.

backgroundColor: this.props.transparent ? 'transparent' : 'rgba(0, 0, 0, 0.4)'

However, it would be more correct to allow the user to select from a wider range of options by creating a new optional property called overlayColor to set the background colour for Modal component as follows:

backgroundColor: this.props.transparent ? 'transparent' : (this.props.overlayColor ? this.props.overlayColor : 'white')

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

11reactions
stepdicommented, Nov 29, 2020

@tcanbolat But it has weird slide animation of the background. Dimmed background slides with the modal contents.

4reactions
deflorilemaruluicommented, Feb 17, 2019

issue still there. check Modal.js

const containerStyles = { backgroundColor: this.props.transparent ? ‘transparent’ : ‘white’, };

it says: ‘white’ RN version 0.58.3

Read more comments on GitHub >

github_iconTop Results From Across the Web

Modal background - HTML & CSS - SitePoint Forums
As far as the “gray” portion under the content box, it goes about half page and the rest of the page is not...
Read more >
Change the background color in a twitter bootstrap modal?
To change the color via: CSS. Put these styles in your stylesheet after the bootstrap styles: .modal-backdrop { background-color: red; } ...
Read more >
Bootstrap 4 modal backdrop color on Codeply
How to change the modal backdrop color in Bootstrap 4 so that it's changed before the modal is shown. Codeply example.
Read more >
How To Use Opacity and Transparency to Create a Modal in ...
See How To Use Color Values with CSS to learn more about working ... White modal box with a black background covering the...
Read more >
Change the background color in bootstrap modal | Tutorials
Change the background color in bootstrap modal, bootstrap modal background color,bootstrap modal background color,Change background color in ...
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