React-modal: How to reset the styles.

Created on 21 Mar 2017  路  8Comments  路  Source: reactjs/react-modal

question

All 8 comments

@JonDotsoy Hi, what do you mean by reset?

yes, but only the styles.

I,ve the next script to reset the estyle.

const resetModalStyle = (() => {
  // Styles
  const initial = null

  const overlay = {
    position: initial,
    top: initial,
    left: initial,
    right: initial,
    bottom: initial,
    backgroundColor: initial,
    WebkitOverflowScrolling: initial,
    zIndex: initial,
  }

  const content = {
    position: initial,
    top: initial,
    left: initial,
    right: initial,
    bottom: initial,
    border: initial,
    background: initial,
    overflow: initial,
    borderRadius: initial,
    outline: initial,
    padding: initial,
  }

  return {overlay, content}
})()

Exists any prop to this same.

You can override the styles using:

<Modal {...other_props} style={resetModalStyle()}>
  ...
</Modal>

The object returned by your function is correct.

Look at react-modal#styles for more information.

In effect, solve it with:

<Modal style={resetModalStyle}>
   ...
</Modal>

Is possible added a noStyle prop to use the style from CSS? This in a next feature?

Example:

<Modal noStyle={true}>
   ...
</Modal>

This would grow the interface of the component.
We would end up with 2 places to set styles (styles : object, noStyle : Bool) which increases complexity.

For now, it's better for the user to provide the zero style.

Something similar to this.

<Modal style={Modal.zeroStyle}>
   ...
</Modal>
Was this page helpful?
0 / 5 - 0 ratings