-
Notifications
You must be signed in to change notification settings - Fork 943
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
Allow adding classes to input widgets (and others) #3431
Comments
In general, if you want to make widgets that look or behave very differently than the core controls, we encourage you to make a custom ipywidget from the cookiecutter and style or change it however you want. For example, there are custom widgets out there that use Vue or Material UI to style a set of controls, and a bootstrap-styled set of components would be welcome as a custom ipywidget package as well. We do have limited styling changes we support with the core widgets, but we also want to keep the core widgets both simple and consistent in styling.
We explicitly moved away from exposing the underlying DOM structure as part of the API in ipywidgets 7, considering the DOM structure an implementation detail that can change. |
Custom widgets are clunky, overkill, and force me to write a bunch of buggy boilerplate when I just want to be able to prototype. I'd rather not use Jupyter and just not provide features to my collaborators than write a bunch of hacked together custom widgets that may or may not compile and load for them and may not even work right. If having access to the DOM is an "implementation detail" then maybe just provide a general purpose |
That's a really intriguing idea. I see you opened another issue exploring some other ideas - is #3433 elaborating on your idea here, or a slightly different take?
In the long run, I think a custom widget is the best bet for a robust solution providing bootstrap-styled components (the cookie cutter takes care of the vast majority of the boilerplate). However, for prototyping and iterating quickly, I agree it can feel heavyweight. |
@jasongrout I ended up pursuing that idea and making a custom widget. It was frankly a terrible experience and it was like pulling teeth to try to figure out how to do what I wanted and I'm not convinced it won't break once Jupyter widgets 8.x is out, but for now it does everything I want. Is there a way to now include this widget in another package as a subpackage or do I need any potential users to install that custom widget in Jupyter lab? |
Problem
I have a
Text
widget that I want to style using Bootstrap classes (I load these separately) likebut at the actual HTML level I end up with something like
which leaves the borders and other bits of styling on the
input
field.I could do some global overrides to the CSS or play all sorts of tricks to fix this, but by far the most robust solution would be to simply allow me to mess with the underlying
input
field.Proposed Solution
It would be straight-forward to allow users to add their own display classes directly to the
input
field using a secondary set of classes from those applied to the enclosingdiv
, e.g.Additional context
This would also help with styling the base
HTML
display widget, too, since that also has an innerwidget-html-content
div that would be nice to be able to restyle to make nicer interfacesThe text was updated successfully, but these errors were encountered: