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

[WIP] Add internal_styles argument to Dash.__init__() for passing custom CSS #435

Closed

Conversation

hinnefe2
Copy link
Contributor

This PR adds an optional kwarg to the Dash constructor to allow passing CSS as a nested dictionary. This CSS gets included in a <style> block in the document head.

The use case I have in mind is hiding the Undo button, as in #234. With these changes you can do something like this

hide_undo_css = {'._dash-undo-redo': {'display': 'none'}}

app = dash.Dash('app', internal_styles=hide_undo_css)

instead of requiring an external stylesheet or messing around with serve_locally.

If this seems like a reasonable addition I'll take a stab at writing some tests. If not, I'm happy to try another approach, or if you're not interested in adding something like this then just let me know and I can close the PR. Also if there's a better place to put this configuration option than kwargs in the constructor please let me know.

Thanks!

This adds an optional kwarg to Dash's init function
to allow passing custom CSS which will get put in a
<style> block in the document <head>.
@alexcjohnson
Copy link
Collaborator

Hi @hinnefe2 - my sincere apologies for not responding to your PR earlier! The consensus here is that the existing solution - a .css file in the assets/ folder, which is now served by default - is at this point nearly as easy as this in the simple case but is more scalable and maintainable as people grow their apps. So we'd like to encourage people to use the assets/ folder rather than learning one thing for simple cases and then having to learn (and switch to) another method later.

If the assets/ solution has shortcomings or could be made easier to learn and use we'd love to hear your thoughts!

@hinnefe2
Copy link
Contributor Author

Hey, no problem! I haven't been keeping up with the CSS serving changes, but being able to put some CSS in a local file which is served by default works for me. Back when I made this it was only possible to source external CSS files and it seemed like a hassle to set up some hosted CSS just for this small change.

Thanks!

@hinnefe2 hinnefe2 closed this Mar 11, 2019
AnnMarieW pushed a commit to AnnMarieW/dash that referenced this pull request Jan 6, 2022
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 this pull request may close these issues.

2 participants