-
Notifications
You must be signed in to change notification settings - Fork 300
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
Add support for theming of IPyWidgets #7161
Comments
We hardcode the background, as IPYWidgets doesn't understand VS Code themes. Changing to a feature requiest. |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
I believe this can be achieved by making a bridge from the vscode theme (CSS variables?) to the jupyterlab theme. ipywidgets (and other libraries for Jupyter) use the JupyterLab CSS variables for respecting the theme. It might just be a matter of defining the needed CSS variables using the current VSCode theme. |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
For anyone interested: Make sure VS Code is closed(at least no jupyter related things should be running on it[ I personally closed it completely and reopened it for editing the below file]). Open file explorer, go to:
Open the ipywidgetsRenderer.js file (using notepad++ or notepad or even VSCode(before letting any jupyter stuff run)) and wherever you see Now the problem is solved. Enjoy :) |
@chandradharkoneti |
Related Stack Overflow question: How can I get rid of or recolour the background of ipywidgets frames in a Jupyter Notebook in VS Code? |
|
Here is a hack for making the print statements readable: css_widget = widgets.HTML("""
<style>
.cell-output-ipywidget-background {
background-color: transparent !important;
}
.cell-output-ipywidget-background pre {
color: white !important;
}
</style>
""")
display(css_widget) |
I added following HTML cell that makes background transparent and binds widgets' foreground text colour and size to that of the active VSCode editor theme. %%html
<style>
.cell-output-ipywidget-background {
background-color: transparent !important;
}
:root {
--jp-widgets-color: var(--vscode-editor-foreground);
--jp-widgets-font-size: var(--vscode-editor-font-size);
}
</style> |
Is there a way to just get rid of the frame it self? Just set margin or padding or box to zero? |
Yes I would really like this! |
bump. |
I think the jupyter team should define some mandatory CSS variables that are to be defined in any frontend, including Jupyter Lab, VS Code, and the output of HTML conversion scripts (e.g. nbconvert, MyST-nb) |
It's actually already defined. ipywidgets requires the same CSS variables as a JupyterLab theme would provide. Note that ipywidgets provides a set of default values for when there is no JupyterLab theme available in the page: https://github.com/jupyter-widgets/ipywidgets/blob/main/packages/controls/css/labvariables.css. The VSCode jupyter extension should make a bridge between the current VSCode theme and the Lab variables. |
I see, so this is really just a missing feature in this extension. The extension should define all these variables similar to how it’s done in this: #7161 (comment) |
I would love to see this one available in a newer version. @DonJayamanne, how can I support this feature so it goes into development? |
Is there any progress here? |
…ark theme (#2120) (See related issues microsoft/vscode-jupyter#7161 and microsoft/vscode-jupyter#9403 for more background) Our CSS override to address the widget theming issue wasn't working somtimes, which was very frustrating, as in Dark Mode our widgets would often appear as they should in light mode. The reason is that the order in which the style sheets get injected is non-deterministic, and as the 'problematic' CSS rule and the override to fix it have the same specificity, it would be 'last one wins'. Sometimes our style-sheet is last and it works... <img width="955" alt="image" src="https://github.com/user-attachments/assets/281524d8-a3d5-4d15-a649-442a21b5ddec" /> And sometimes the IPyWidgets 'force it to white' rule is last so the issue persists... <img width="960" alt="image" src="https://github.com/user-attachments/assets/f60f762e-0312-49de-9a2d-6f3cf4833b20" /> The unfortunate best _hack_ I could come up with is to programmatically ensure the override CSS rule is always last in the `style`s in the header. Not pretty, but it works.
…ark theme (#2120) (See related issues microsoft/vscode-jupyter#7161 and microsoft/vscode-jupyter#9403 for more background) Our CSS override to address the widget theming issue wasn't working somtimes, which was very frustrating, as in Dark Mode our widgets would often appear as they should in light mode. The reason is that the order in which the style sheets get injected is non-deterministic, and as the 'problematic' CSS rule and the override to fix it have the same specificity, it would be 'last one wins'. Sometimes our style-sheet is last and it works... <img width="955" alt="image" src="https://github.com/user-attachments/assets/281524d8-a3d5-4d15-a649-442a21b5ddec" /> And sometimes the IPyWidgets 'force it to white' rule is last so the issue persists... <img width="960" alt="image" src="https://github.com/user-attachments/assets/f60f762e-0312-49de-9a2d-6f3cf4833b20" /> The unfortunate best _hack_ I could come up with is to programmatically ensure the override CSS rule is always last in the `style`s in the header. Not pretty, but it works.
Would love to see this too |
Environment data
The text was updated successfully, but these errors were encountered: