display
Display a Python object in the current component.
def display(*objs, **kwargs):
...
Supported objects
Any object that can be displayed in the Jupyter notebook can be displayed in Solara as well. This means that plotly, pandas, vaex and other libraries that have a display function will work out of the box in Solara.
However, if you require callback functions, use the specific Solara components, e.g.:
import solara
import pandas as pd
import plotly.express as px
df = px.data.gapminder()
fig = px.scatter(df, x="gdpPercap", y="lifeExp")
button = solara.Button("Click me")
@solara.component
def Page():
# You can use solara.display directly
solara.display(fig)
# Or use the IPython display function, which is in the global scope
# in Jupyter and Solara
display(df)
with solara.Card("Some card"):
# you can use display to add existing elements to the parent's
# children
display(button)
country | continent | year | lifeExp | pop | gdpPercap | iso_alpha | iso_num | |
---|---|---|---|---|---|---|---|---|
0 | Afghanistan | Asia | 1952 | 28.801 | 8425333 | 779.445314 | AFG | 4 |
1 | Afghanistan | Asia | 1957 | 30.332 | 9240934 | 820.853030 | AFG | 4 |
2 | Afghanistan | Asia | 1962 | 31.997 | 10267083 | 853.100710 | AFG | 4 |
3 | Afghanistan | Asia | 1967 | 34.020 | 11537966 | 836.197138 | AFG | 4 |
4 | Afghanistan | Asia | 1972 | 36.088 | 13079460 | 739.981106 | AFG | 4 |
... | ... | ... | ... | ... | ... | ... | ... | ... |
1699 | Zimbabwe | Africa | 1987 | 62.351 | 9216418 | 706.157306 | ZWE | 716 |
1700 | Zimbabwe | Africa | 1992 | 60.377 | 10704340 | 693.420786 | ZWE | 716 |
1701 | Zimbabwe | Africa | 1997 | 46.809 | 11404948 | 792.449960 | ZWE | 716 |
1702 | Zimbabwe | Africa | 2002 | 39.989 | 11926563 | 672.038623 | ZWE | 716 |
1703 | Zimbabwe | Africa | 2007 | 43.487 | 12311143 | 469.709298 | ZWE | 716 |
1704 rows × 8 columns
Some card
Live output
Arguments
objs
: The objects to display.kwargs
: Keyword arguments to pass to the IPython display function.