cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

How can I change the font size on ipywidgets in a Databricks notebook?

Michael_Marquis
New Contributor II

I'm trying to create a simple UI for a notebook using the recently implemented support for ipywidgets, but I'm having a hard time figuring out how to change certain style attributes like font size and color in widgets that should accept those style parameters according the the ipywidgets documentation.

For example, if I run the following code snippet (taken directly from the ipywidget docs), none of these style parameters seems to have any effect on the widget that is created:

b3 = widgets.Button(description='Styled button', style=dict(
	    font_style='italic',
	    font_variant="small-caps",
	    text_color='red',
	    text_decoration='underline'
	     ))
display(b3)

Similarly, if I run b3.style.keys in a new cell after executing the above code, the output doesn't include any of those style parameters.

I've run into this same issue with a number of different widgets, and it's really inconvenient not to be able to change font sizes on individual widgets even when I scale them. Is this an additional limitation of ipywidgets in Databricks? It's not listed as such on on the Databricks website so I'm wondering if there's a simple answer that I'm missing.

1 REPLY 1

Miguel_Suarez
New Contributor III
New Contributor III

Hey Michael,

The example you're trying to run is for ipywidgets 8, we currently have ipywidgets 7-which has fewer button customizations. I believe the only font customization available in 7 is "font_weigh t" (no space).

I hope this helps.

Best,

Miguel

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.