Skip to content

Commit c31981f

Browse files
committed
Add theming docs for Vega-Lite
1 parent e1a0f46 commit c31981f

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed

content/library/api/charts/altair_chart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ description: st.altair_chart displays a chart using the Altair library.
1010

1111
Altair charts are displayed using the Streamlit theme by default. This theme is sleek, user-friendly, and incorporates Streamlit's color palette. The added benefit is that your charts better integrate with the rest of your app's design.
1212

13-
The new Streamlit theme is available from Streamlit 1.16.0 through the `theme="streamlit"` keyword argument. To disable it, and use Altair's native theme, use `theme=None` instead.
13+
The Streamlit theme is available from Streamlit 1.16.0 through the `theme="streamlit"` keyword argument. To disable it, and use Altair's native theme, use `theme=None` instead.
1414

1515
Let's look at an example of charts with the Streamlit theme and the native Altair theme:
1616

content/library/api/charts/plotly_chart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ description: st.plotly_chart displays an interactive Plotly chart.
1010

1111
Plotly charts are displayed using the Streamlit theme by default. This theme is sleek, user-friendly, and incorporates Streamlit's color palette. The added benefit is that your charts better integrate with the rest of your app's design.
1212

13-
The new Streamlit theme is available from Streamlit 1.16.0 through the `theme="streamlit"` keyword argument. To disable it, and use Plotly's native theme, use `theme=None` instead.
13+
The Streamlit theme is available from Streamlit 1.16.0 through the `theme="streamlit"` keyword argument. To disable it, and use Plotly's native theme, use `theme=None` instead.
1414

1515
Let's look at an example of charts with the Streamlit theme and the native Plotly theme:
1616

content/library/api/charts/vega_lite_chart.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,53 @@ description: st.vega_lite_chart displays a chart using the Vega-Lite library.
55
---
66

77
<Autofunction function="streamlit.vega_lite_chart" />
8+
9+
### Theming
10+
11+
Vega-Lite charts are displayed using the Streamlit theme by default. This theme is sleek, user-friendly, and incorporates Streamlit's color palette. The added benefit is that your charts better integrate with the rest of your app's design.
12+
13+
The Streamlit theme is available from Streamlit 1.16.0 through the `theme="streamlit"` keyword argument. To disable it, and use Vega-Lite's native theme, use `theme=None` instead.
14+
15+
Let's look at an example of charts with the Streamlit theme and the native Vega-Lite theme:
16+
17+
```python
18+
import streamlit as st
19+
from vega_datasets import data
20+
21+
source = data.cars()
22+
23+
chart = {
24+
"mark": "point",
25+
"encoding": {
26+
"x": {
27+
"field": "Horsepower",
28+
"type": "quantitative",
29+
},
30+
"y": {
31+
"field": "Miles_per_Gallon",
32+
"type": "quantitative",
33+
},
34+
"color": {"field": "Origin", "type": "nominal"},
35+
"shape": {"field": "Origin", "type": "nominal"},
36+
},
37+
}
38+
39+
tab1, tab2 = st.tabs(["Streamlit theme (default)", "Vega-Lite native theme"])
40+
41+
with tab1:
42+
# Use the Streamlit theme.
43+
# This is the default. So you can also omit the theme argument.
44+
st.vega_lite_chart(
45+
source, chart, use_container_width=use_container_width, theme="streamlit"
46+
)
47+
with tab2:
48+
st.vega_lite_chart(
49+
source, chart, use_container_width=use_container_width, theme=None
50+
)
51+
```
52+
53+
Click the tabs in the interactive app below to see the charts with the Streamlit theme enabled and disabled.
54+
55+
<Cloud src="https://doc-vega-lite-theme.streamlit.app/?embed=true" height="500" />
56+
57+
If you're wondering if your own customizations will still be taken into account, don't worry! If you're an experienced Vega-Lite user and like to have your own special customizations, your changes in the chart configurations will still be taken into account.

0 commit comments

Comments
 (0)