Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I set a className on the rendered Portal element in order to style it with CSS? #1

Closed
Zenwolf opened this issue Apr 6, 2015 · 4 comments · Fixed by #7
Closed

Comments

@Zenwolf
Copy link

Zenwolf commented Apr 6, 2015

I would like to style the root div element using a CSS class. Is there a way to set a className on the Portal, and not just its child content?

@tajo
Copy link
Owner

tajo commented Apr 6, 2015

Why do you need that? Why is not good enough to style just its child content? (You are asking about the empty div that is dynamically appended to the document.body, right?)

@Zenwolf
Copy link
Author

Zenwolf commented Apr 6, 2015

One example is if a web application has some general styles that apply to all HTML elements, such as position: relative which is generally desired except in special circumstances. One special circumstance is a modal dialog. The child Portal content cannot escape from its positioned parent, which may inherit positioning from generic CSS. In this case, being able to apply a style makes it much easier to make the modal behavior of absolutely positioning the portal content across the entire screen. Does that make sense?

@tajo
Copy link
Owner

tajo commented Apr 7, 2015

Oh, that's a very valid point.

Is it good enough to add a CSS class (e.g react-portal) to the portal root element? I believe React inline styles (and passing them as an another prop) can't be used since the portal root div is created out of React's scope. It would be nice to achieve that though (any idea how?). Will you send a PR?

@tajo
Copy link
Owner

tajo commented Apr 7, 2015

Is there a way to set a className on the Portal

Or this. It's more explicit for users, therefore better.

@tajo tajo closed this as completed in #7 May 9, 2015
tajo pushed a commit that referenced this issue Feb 2, 2016
merge with upstream
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants