Skip to content

Custom Background Colour for Modal Display #18398

Description

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')

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Ran CommandsOne of our bots successfully processed a command.Type: EnhancementA new feature or enhancement of an existing feature.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions