streamlit-nightly 1.45.2.dev20250615__py3-none-any.whl → 1.45.2.dev20250617__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. streamlit/commands/navigation.py +39 -5
  2. streamlit/commands/page_config.py +48 -20
  3. streamlit/config.py +75 -33
  4. streamlit/dataframe_util.py +2 -3
  5. streamlit/elements/alert.py +36 -28
  6. streamlit/elements/arrow.py +1 -1
  7. streamlit/elements/code.py +29 -12
  8. streamlit/elements/deck_gl_json_chart.py +1 -1
  9. streamlit/elements/doc_string.py +8 -2
  10. streamlit/elements/exception.py +9 -7
  11. streamlit/elements/form.py +29 -2
  12. streamlit/elements/heading.py +34 -13
  13. streamlit/elements/json.py +8 -3
  14. streamlit/elements/layouts.py +69 -13
  15. streamlit/elements/lib/color_util.py +1 -1
  16. streamlit/elements/lib/image_utils.py +3 -5
  17. streamlit/elements/markdown.py +57 -24
  18. streamlit/elements/media.py +31 -24
  19. streamlit/elements/metric.py +11 -4
  20. streamlit/elements/plotly_chart.py +1 -1
  21. streamlit/elements/progress.py +9 -3
  22. streamlit/elements/spinner.py +11 -3
  23. streamlit/elements/text.py +12 -4
  24. streamlit/elements/vega_charts.py +1 -1
  25. streamlit/elements/widgets/audio_input.py +8 -3
  26. streamlit/elements/widgets/button.py +7 -6
  27. streamlit/elements/widgets/camera_input.py +9 -3
  28. streamlit/elements/widgets/chat.py +23 -11
  29. streamlit/elements/widgets/checkbox.py +24 -6
  30. streamlit/elements/widgets/color_picker.py +13 -4
  31. streamlit/elements/widgets/file_uploader.py +9 -3
  32. streamlit/elements/widgets/number_input.py +10 -2
  33. streamlit/elements/widgets/radio.py +12 -3
  34. streamlit/elements/widgets/select_slider.py +9 -3
  35. streamlit/elements/widgets/selectbox.py +9 -3
  36. streamlit/elements/widgets/slider.py +10 -2
  37. streamlit/elements/widgets/text_widgets.py +20 -4
  38. streamlit/elements/widgets/time_widgets.py +17 -10
  39. streamlit/proto/NewSession_pb2.py +16 -16
  40. streamlit/proto/NewSession_pb2.pyi +7 -2
  41. streamlit/proto/PageConfig_pb2.py +5 -5
  42. streamlit/proto/PageConfig_pb2.pyi +16 -0
  43. streamlit/runtime/context.py +22 -1
  44. streamlit/runtime/credentials.py +3 -1
  45. streamlit/runtime/state/query_params_proxy.py +2 -0
  46. streamlit/runtime/state/session_state.py +4 -2
  47. streamlit/static/index.html +1 -1
  48. streamlit/static/manifest.json +218 -218
  49. streamlit/static/static/js/{ErrorOutline.esm.DeqDGwEO.js → ErrorOutline.esm.1znYgwZa.js} +1 -1
  50. streamlit/static/static/js/{FileDownload.esm.--sYVXOa.js → FileDownload.esm.MlshysxD.js} +1 -1
  51. streamlit/static/static/js/{FileHelper.bloGbv2W.js → FileHelper.DJjfImdO.js} +1 -1
  52. streamlit/static/static/js/{FormClearHelper.CYKg4prI.js → FormClearHelper.tzcHfSQm.js} +1 -1
  53. streamlit/static/static/js/{Hooks.B16qdpVx.js → Hooks.CUwe1mU9.js} +1 -1
  54. streamlit/static/static/js/{InputInstructions.DMO4B42t.js → InputInstructions.ibDI_m0Z.js} +1 -1
  55. streamlit/static/static/js/{ProgressBar.BH1ZwSEk.js → ProgressBar.B4yod1d4.js} +1 -1
  56. streamlit/static/static/js/{RenderInPortalIfExists.IgdXklou.js → RenderInPortalIfExists.sxtf_tkp.js} +1 -1
  57. streamlit/static/static/js/{Toolbar.DkIytKhC.js → Toolbar.D2TSK_7z.js} +1 -1
  58. streamlit/static/static/js/{base-input.CAahP9oF.js → base-input.DBGTsu79.js} +1 -1
  59. streamlit/static/static/js/{checkbox.k1RuPBbZ.js → checkbox.Cv3M11iz.js} +1 -1
  60. streamlit/static/static/js/{createSuper.ButEKFwQ.js → createSuper.CZYzqRu7.js} +1 -1
  61. streamlit/static/static/js/{data-grid-overlay-editor.7XGvfjSS.js → data-grid-overlay-editor.Dnwp2SeP.js} +1 -1
  62. streamlit/static/static/js/{downloader.DSilreQW.js → downloader.OkIJTahw.js} +1 -1
  63. streamlit/static/static/js/{es6.yDFTfvZI.js → es6.CWUYJnwB.js} +2 -2
  64. streamlit/static/static/js/{iframeResizer.contentWindow.BSskBUmQ.js → iframeResizer.contentWindow.BGMetL4r.js} +1 -1
  65. streamlit/static/static/js/{index.Iveq4NZV.js → index.BLLY_wCb.js} +1 -1
  66. streamlit/static/static/js/{index.BG8RaQ8E.js → index.BNQdHQ9A.js} +1 -1
  67. streamlit/static/static/js/{index.BcW5X6V5.js → index.BRUfGLJs.js} +1 -1
  68. streamlit/static/static/js/{index.CWeNa-FP.js → index.BZhFm-tC.js} +1 -1
  69. streamlit/static/static/js/{index.BAXqDnQ9.js → index.Bi_xDLKC.js} +1 -1
  70. streamlit/static/static/js/{index.DNTQOI5W.js → index.Bio4VfuK.js} +1 -1
  71. streamlit/static/static/js/{index.ChhNrUVT.js → index.BlRNHzJT.js} +1 -1
  72. streamlit/static/static/js/{index.D9muCjoC.js → index.BvPXgYL1.js} +1 -1
  73. streamlit/static/static/js/{index.FC1jA29Z.js → index.C8UyejlW.js} +1 -1
  74. streamlit/static/static/js/{index.bQ9PFxvm.js → index.CATKfyKP.js} +1 -1
  75. streamlit/static/static/js/{index.Cdi_Zw1a.js → index.CImNFEsN.js} +1 -1
  76. streamlit/static/static/js/{index.ClCtylIR.js → index.CP9S4-UC.js} +1 -1
  77. streamlit/static/static/js/{index.C0xV4csm.js → index.CaH9iZrA.js} +1 -1
  78. streamlit/static/static/js/{index.DslKxDZN.js → index.CfU3gX6G.js} +1 -1
  79. streamlit/static/static/js/{index.RQlZs06L.js → index.CghNjnWG.js} +1 -1
  80. streamlit/static/static/js/index.ClByuhfh.js +783 -0
  81. streamlit/static/static/js/{index.DGrpmtEI.js → index.CyScXVPk.js} +1 -1
  82. streamlit/static/static/js/{index.Bo1tG5CG.js → index.D3yL8Boz.js} +5 -5
  83. streamlit/static/static/js/{index.EgFq4OeP.js → index.DHrbHxMA.js} +1 -1
  84. streamlit/static/static/js/{index.y-bXsZ3U.js → index.DXby5BWo.js} +1 -1
  85. streamlit/static/static/js/{index.9VWuu9bJ.js → index.Dgicxx_R.js} +1 -1
  86. streamlit/static/static/js/{index.DLBGcvEx.js → index.DhZtGReO.js} +1 -1
  87. streamlit/static/static/js/{index.ChBsbacw.js → index.DqoNxwFW.js} +1 -1
  88. streamlit/static/static/js/{index.80yI-jzZ.js → index.DrAi2KWE.js} +1 -1
  89. streamlit/static/static/js/{index.O4EQwJsZ.js → index.DuQBFADi.js} +1 -1
  90. streamlit/static/static/js/{index.BoHCDi97.js → index.DxX0zYtM.js} +1 -1
  91. streamlit/static/static/js/{index.CzY5--PW.js → index.GbpCpBCj.js} +1 -1
  92. streamlit/static/static/js/{index.D6veSOdZ.js → index.aKXX7Ba_.js} +1 -1
  93. streamlit/static/static/js/{index.DqbaNLFW.js → index.bK_LT6WV.js} +1 -1
  94. streamlit/static/static/js/{index.BY47W7LH.js → index.cFdge3NU.js} +1 -1
  95. streamlit/static/static/js/{index.CKJtZooB.js → index.cbAks8a8.js} +1 -1
  96. streamlit/static/static/js/{index.tnjDy4iv.js → index.eeGQgksq.js} +1 -1
  97. streamlit/static/static/js/{index.CIXRC_j_.js → index.fybg-SX6.js} +1 -1
  98. streamlit/static/static/js/{index.ClCMQ4iK.js → index.igD8dUid.js} +1 -1
  99. streamlit/static/static/js/{index.BsCehkC8.js → index.jzzHl6U7.js} +1 -1
  100. streamlit/static/static/js/{index.DSpbUJvK.js → index.vJGalypl.js} +1 -1
  101. streamlit/static/static/js/{index.BZqoA_aJ.js → index.yh03tq2H.js} +1 -1
  102. streamlit/static/static/js/{input.5dpw-Sqs.js → input.DG4M8O5Z.js} +1 -1
  103. streamlit/static/static/js/{memory.8YWsO_82.js → memory.cZDDDDRN.js} +1 -1
  104. streamlit/static/static/js/{mergeWith.1afHaDFE.js → mergeWith.CbuU4RN8.js} +1 -1
  105. streamlit/static/static/js/{number-overlay-editor.CrclsoQd.js → number-overlay-editor.GDhzbbBH.js} +1 -1
  106. streamlit/static/static/js/{possibleConstructorReturn.Dq7g1SWn.js → possibleConstructorReturn.CJFaNdfh.js} +1 -1
  107. streamlit/static/static/js/{sandbox.ZlQ0WZlh.js → sandbox.SJvDMGmc.js} +1 -1
  108. streamlit/static/static/js/{textarea.CY5cwdtO.js → textarea.CA5HbAYe.js} +1 -1
  109. streamlit/static/static/js/{timepicker.DMqTkd3V.js → timepicker.Dw_Jp_TE.js} +1 -1
  110. streamlit/static/static/js/{toConsumableArray.Bm0yYM5M.js → toConsumableArray.DrYe4LQW.js} +1 -1
  111. streamlit/static/static/js/{uniqueId.kDXXTYvS.js → uniqueId.D-hUXA0O.js} +1 -1
  112. streamlit/static/static/js/{useBasicWidgetState.ClCgm0D-.js → useBasicWidgetState.ByTJlmUY.js} +1 -1
  113. streamlit/static/static/js/{useOnInputChange.Cwcz7NJx.js → useOnInputChange.4waR08fC.js} +1 -1
  114. streamlit/static/static/js/{withFullScreenWrapper.CRbf9QMV.js → withFullScreenWrapper.BbZgX6-q.js} +1 -1
  115. {streamlit_nightly-1.45.2.dev20250615.dist-info → streamlit_nightly-1.45.2.dev20250617.dist-info}/METADATA +1 -1
  116. {streamlit_nightly-1.45.2.dev20250615.dist-info → streamlit_nightly-1.45.2.dev20250617.dist-info}/RECORD +120 -120
  117. streamlit/static/static/js/index.VE3QHoXq.js +0 -783
  118. {streamlit_nightly-1.45.2.dev20250615.data → streamlit_nightly-1.45.2.dev20250617.data}/scripts/streamlit.cmd +0 -0
  119. {streamlit_nightly-1.45.2.dev20250615.dist-info → streamlit_nightly-1.45.2.dev20250617.dist-info}/WHEEL +0 -0
  120. {streamlit_nightly-1.45.2.dev20250615.dist-info → streamlit_nightly-1.45.2.dev20250617.dist-info}/entry_points.txt +0 -0
  121. {streamlit_nightly-1.45.2.dev20250615.dist-info → streamlit_nightly-1.45.2.dev20250617.dist-info}/top_level.txt +0 -0
@@ -120,7 +120,8 @@ def navigation(
120
120
  To create labeled sections or page groupings within the navigation
121
121
  menu, ``pages`` must be a dictionary. Each key is the label of a
122
122
  section and each value is the list of page-like objects for
123
- that section.
123
+ that section. If you use ``position="top"``, each grouping will be a
124
+ collapsible item in the navigation menu.
124
125
 
125
126
  When you use a string or path as a page-like object, they are
126
127
  internally passed to ``st.Page`` and converted to ``StreamlitPage``
@@ -128,11 +129,11 @@ def navigation(
128
129
  path inferred from its path or filename. To customize these attributes
129
130
  for your page, initialize your page with ``st.Page``.
130
131
 
131
- position : "sidebar", "hidden", or "top"
132
+ position : "sidebar", "top", or "hidden"
132
133
  The position of the navigation menu. If this is ``"sidebar"``
133
134
  (default), the navigation widget appears at the top of the sidebar. If
134
- this is ``"hidden"``, the navigation widget is not displayed. If this
135
- is ``"top"``, the navigation appears in the top header of the app.
135
+ this is ``"top"``, the navigation appears in the top header of the app.
136
+ If this is ``"hidden"``, the navigation widget is not displayed.
136
137
 
137
138
  If there is only one page in ``pages``, the navigation will be hidden
138
139
  for any value of ``position``.
@@ -148,6 +149,8 @@ def navigation(
148
149
  ``expanded=False`` on a rerun, the menu will stay expanded and a
149
150
  collapse button will be displayed.
150
151
 
152
+ The parameter is only used when ``position="sidebar"``.
153
+
151
154
  Returns
152
155
  -------
153
156
  StreamlitPage
@@ -226,7 +229,38 @@ def navigation(
226
229
  https://doc-navigation-example-2.streamlit.app/
227
230
  height: 300px
228
231
 
229
- **Example 3: Stateful widgets across multiple pages**
232
+
233
+ **Example 3: Use top navigation**
234
+
235
+ You can use the ``position`` parameter to place the navigation at the top
236
+ of the app. This is useful for apps with a lot of pages because it allows
237
+ you to create collapsible sections for each group of pages. The following
238
+ example uses the same directory structure as Example 2 and shows how to
239
+ create a top navigation menu.
240
+
241
+ ``streamlit_app.py``:
242
+
243
+ >>> import streamlit as st
244
+ >>>
245
+ >>> pages = {
246
+ ... "Your account": [
247
+ ... st.Page("create_account.py", title="Create your account"),
248
+ ... st.Page("manage_account.py", title="Manage your account"),
249
+ ... ],
250
+ ... "Resources": [
251
+ ... st.Page("learn.py", title="Learn about us"),
252
+ ... st.Page("trial.py", title="Try it out"),
253
+ ... ],
254
+ ... }
255
+ >>>
256
+ >>> pg = st.navigation(pages, position="top")
257
+ >>> pg.run()
258
+
259
+ .. output::
260
+ https://doc-navigation-top.streamlit.app/
261
+ height: 300px
262
+
263
+ **Example 4: Stateful widgets across multiple pages**
230
264
 
231
265
  Call widget functions in your entrypoint file when you want a widget to be
232
266
  stateful across pages. Assign keys to your common widgets and access their
@@ -110,26 +110,34 @@ def _get_favicon_string(page_icon: PageIcon) -> str:
110
110
  def set_page_config(
111
111
  page_title: str | None = None,
112
112
  page_icon: PageIcon | None = None,
113
- layout: Layout = "centered",
114
- initial_sidebar_state: InitialSideBarState = "auto",
113
+ layout: Layout | None = None,
114
+ initial_sidebar_state: InitialSideBarState | None = None,
115
115
  menu_items: MenuItems | None = None,
116
116
  ) -> None:
117
117
  """
118
- Configures the default settings of the page.
118
+ Configure the default settings of the page.
119
119
 
120
- .. note::
121
- This must be the first Streamlit command used on an app page, and must only
122
- be set once per page.
120
+ This command can be called multiple times in a script run to dynamically
121
+ change the page configuration. The calls are additive, with each successive
122
+ call overriding only the parameters that are specified.
123
123
 
124
124
  Parameters
125
125
  ----------
126
126
  page_title: str or None
127
- The page title, shown in the browser tab. If None, defaults to the
128
- filename of the script ("app.py" would show "app Streamlit").
127
+ The page title, shown in the browser tab. If this is ``None``
128
+ (default), the page title is inherited from the previous call of
129
+ ``st.set_page_config``. If this is ``None`` and no previous call
130
+ exists, the page title is inferred from the page source.
131
+
132
+ If a page source is a Python file, its inferred title is derived from
133
+ the filename. If a page source is a callable object, its inferred title
134
+ is derived from the callable's name.
129
135
 
130
136
  page_icon : Anything supported by st.image (except list), str, or None
131
- The page favicon. If ``page_icon`` is ``None`` (default), the favicon
132
- will be a monochrome Streamlit logo.
137
+ The page favicon. If ``page_icon`` is ``None`` (default), the page icon
138
+ is inherited from the previous call of ``st.set_page_config``. If this
139
+ is ``None`` and no previous call exists, the favicon is a monochrome
140
+ Streamlit logo.
133
141
 
134
142
  In addition to the types supported by |st.image|_ (except list), the
135
143
  following strings are valid:
@@ -160,17 +168,29 @@ def set_page_config(
160
168
  .. |st.image| replace:: ``st.image``
161
169
  .. _st.image: https://docs.streamlit.io/develop/api-reference/media/st.image
162
170
 
163
- layout: "centered" or "wide"
164
- How the page content should be laid out. Defaults to "centered",
165
- which constrains the elements into a centered column of fixed width;
166
- "wide" uses the entire screen.
171
+ layout: "centered", "wide", or None
172
+ How the page content should be laid out. If this is ``None`` (default),
173
+ the page layout is inherited from the previous call of
174
+ ``st.set_page_config``. If this is ``None`` and no previous call
175
+ exists, the page layout is ``"centered"``.
176
+
177
+ ``"centered"`` constrains the elements into a centered column of fixed
178
+ width. ``"wide"`` uses the entire screen.
179
+
180
+ initial_sidebar_state: "auto", "expanded", "collapsed", or None
181
+ How the sidebar should start out. If this is ``None`` (default), the
182
+ sidebar state is inherited from the previous call of
183
+ ``st.set_page_config``. If no previous call exists, the sidebar state
184
+ is ``"auto"``.
185
+
186
+ The folowing states are supported:
187
+
188
+ - ``"auto"``: The sidebar is hidden on small devices and shown otherwise.
189
+ - ``"expanded"``: The sidebar is shown initially.
190
+ - ``"collapsed"``: The sidebar is hidden initially.
167
191
 
168
- initial_sidebar_state: "auto", "expanded", or "collapsed"
169
- How the sidebar should start out. Defaults to "auto",
170
- which hides the sidebar on small devices and shows it otherwise.
171
- "expanded" shows the sidebar initially; "collapsed" hides it.
172
- In most cases, you should just use "auto", otherwise the app will
173
- look bad when embedded and viewed on mobile.
192
+ In most cases, ``"auto"`` provides the best user experience across
193
+ devices of different sizes.
174
194
 
175
195
  menu_items: dict
176
196
  Configure the menu that appears on the top-right side of this app.
@@ -187,6 +207,8 @@ def set_page_config(
187
207
  If None, only shows Streamlit's default About text.
188
208
 
189
209
  The URL may also refer to an email address e.g. ``mailto:john@example.com``.
210
+ To remove an item that was specified in a previous call to
211
+ ``st.set_page_config``, set its value to ``None`` in the dictionary.
190
212
 
191
213
  Example
192
214
  -------
@@ -218,6 +240,9 @@ def set_page_config(
218
240
  pb_layout = PageConfigProto.CENTERED
219
241
  elif layout == "wide":
220
242
  pb_layout = PageConfigProto.WIDE
243
+ elif layout is None:
244
+ # Allows for multiple (additive) calls to set_page_config
245
+ pb_layout = PageConfigProto.LAYOUT_UNSET
221
246
  else:
222
247
  # Note: Pylance incorrectly notes this error as unreachable
223
248
  raise StreamlitInvalidPageLayoutError(layout=layout)
@@ -231,6 +256,9 @@ def set_page_config(
231
256
  pb_sidebar_state = PageConfigProto.EXPANDED
232
257
  elif initial_sidebar_state == "collapsed":
233
258
  pb_sidebar_state = PageConfigProto.COLLAPSED
259
+ elif initial_sidebar_state is None:
260
+ # Allows for multiple (additive) calls to set_page_config
261
+ pb_sidebar_state = PageConfigProto.SIDEBAR_UNSET
234
262
  else:
235
263
  # Note: Pylance incorrectly notes this error as unreachable
236
264
  raise StreamlitInvalidSidebarStateError(
streamlit/config.py CHANGED
@@ -676,12 +676,11 @@ _create_section("server", "Settings for the Streamlit server")
676
676
  _create_option(
677
677
  "server.folderWatchList",
678
678
  description="""
679
- List of folders to watch for changes.
679
+ List of directories to watch for changes.
680
680
 
681
- By default, Streamlit watches for files in the current working directory.
682
- Use this parameter to specify additional folders to watch.
683
-
684
- Note: This is a list of absolute paths.
681
+ By default, Streamlit watches files in the current working directory
682
+ and its subdirectories. Use this option to specify additional
683
+ directories to watch. Paths must be absolute.
685
684
  """,
686
685
  default_val=[],
687
686
  multiple=True,
@@ -690,9 +689,12 @@ _create_option(
690
689
  _create_option(
691
690
  "server.folderWatchBlacklist",
692
691
  description="""
693
- List of folders that should not be watched for changes.
692
+ List of directories to ignore for changes.
694
693
 
695
- Relative paths will be taken as relative to the current working directory.
694
+ By default, Streamlit watches files in the current working directory
695
+ and its subdirectories. Use this option to specify exceptions within
696
+ watched directories. Paths can be absolute or relative to the current
697
+ working directory.
696
698
 
697
699
  Example: ['/home/user1/env', 'relative/path/to/folder']
698
700
  """,
@@ -745,6 +747,17 @@ def _server_headless() -> bool:
745
747
  )
746
748
 
747
749
 
750
+ _create_option(
751
+ "server.showEmailPrompt",
752
+ description="""
753
+ Whether to show a terminal prompt for the user to enter their email
754
+ address when they run Streamlit for the first time. If you set
755
+ `server.headless=True`, Streamlit will not show this prompt.
756
+ """,
757
+ default_val=True,
758
+ type_=bool,
759
+ )
760
+
748
761
  _create_option(
749
762
  "server.runOnSave",
750
763
  description="""
@@ -829,9 +842,11 @@ _create_option(
829
842
  _create_option(
830
843
  "server.corsAllowedOrigins",
831
844
  description="""
832
- If CORS protection is enabled (when server.enableCORS=True), allows an
833
- app developer to set a list of allowed origins that the Streamlit server
834
- will accept traffic from.
845
+ Allowed list of origins.
846
+
847
+ If CORS protection is enabled (`server.enableCORS=True`), use this
848
+ option to set a list of allowed origins that the Streamlit server will
849
+ accept traffic from.
835
850
 
836
851
  This config option does nothing if CORS protection is disabled.
837
852
 
@@ -1141,14 +1156,14 @@ _create_theme_options(
1141
1156
  "font",
1142
1157
  categories=["theme", CustomThemeCategories.SIDEBAR],
1143
1158
  description="""
1144
- The font family for all text, except code blocks. This can be one of
1145
- the following:
1159
+ The font family for all text, except code blocks.
1146
1160
 
1161
+ This can be one of the following:
1147
1162
  - "sans-serif"
1148
1163
  - "serif"
1149
1164
  - "monospace"
1150
- - the `family` value for a custom font table under [[theme.fontFaces]]
1151
- - a comma-separated list of these (as a single string) to specify
1165
+ - The `family` value for a custom font table under [[theme.fontFaces]]
1166
+ - A comma-separated list of these (as a single string) to specify
1152
1167
  fallbacks
1153
1168
 
1154
1169
  For example, you can use the following:
@@ -1161,29 +1176,43 @@ _create_theme_options(
1161
1176
  "codeFont",
1162
1177
  categories=["theme", CustomThemeCategories.SIDEBAR],
1163
1178
  description="""
1164
- The font family to use for code (monospace) in the sidebar. This can be
1165
- one of the following:
1179
+ The font family to use for code (monospace) in the sidebar.
1166
1180
 
1181
+ This can be one of the following:
1167
1182
  - "sans-serif"
1168
1183
  - "serif"
1169
1184
  - "monospace"
1170
- - the `family` value for a custom font table under [[theme.fontFaces]]
1171
- - a comma-separated list of these (as a single string) to specify
1185
+ - The `family` value for a custom font table under [[theme.fontFaces]]
1186
+ - A comma-separated list of these (as a single string) to specify
1172
1187
  fallbacks
1173
1188
  """,
1174
1189
  )
1175
1190
 
1191
+ _create_theme_options(
1192
+ "codeFontSize",
1193
+ categories=["theme", CustomThemeCategories.SIDEBAR],
1194
+ description="""
1195
+ Sets the font size (in pixels or rem) for code blocks and code text.
1196
+
1197
+ This applies to code blocks (ex: `st.code`), as well as font in `st.json` and `st.help`.
1198
+ It does not apply to inline code, which is set by default to 0.75em.
1199
+
1200
+ When unset, the code font size will be 0.875rem.
1201
+ """,
1202
+ )
1203
+
1176
1204
  _create_theme_options(
1177
1205
  "headingFont",
1178
1206
  categories=["theme", CustomThemeCategories.SIDEBAR],
1179
1207
  description="""
1180
- The font family to use for headings. This can be one of the following:
1208
+ The font family to use for headings.
1181
1209
 
1210
+ This can be one of the following:
1182
1211
  - "sans-serif"
1183
1212
  - "serif"
1184
1213
  - "monospace"
1185
- - the `family` value for a custom font table under [[theme.fontFaces]]
1186
- - a comma-separated list of these (as a single string) to specify
1214
+ - The `family` value for a custom font table under [[theme.fontFaces]]
1215
+ - A comma-separated list of these (as a single string) to specify
1187
1216
  fallbacks
1188
1217
 
1189
1218
  If no heading font is set, Streamlit uses `theme.font` for headings.
@@ -1196,21 +1225,27 @@ _create_theme_options(
1196
1225
  description="""
1197
1226
  An array of fonts to use in your app.
1198
1227
 
1199
- Each font in the array is a table (dictionary) with the following three
1200
- attributes: family, url, weight, and style.
1228
+ Each font in the array is a table (dictionary) that can have the
1229
+ following attributes, closely resembling CSS font-face definitions:
1230
+ - family
1231
+ - url
1232
+ - weight (optional)
1233
+ - style (optional)
1234
+ - unicodeRange (optional)
1201
1235
 
1202
1236
  To host a font with your app, enable static file serving with
1203
1237
  `server.enableStaticServing=true`.
1204
1238
 
1205
- You can define multiple [[theme.fontFaces]] tables.
1239
+ You can define multiple [[theme.fontFaces]] tables, including multiple
1240
+ tables with the same family if your font is defined by multiple files.
1206
1241
 
1207
- For example, each font is defined in a [[theme.fontFaces]] table as
1208
- follows:
1242
+ For example, a font hosted with your app may have a [[theme.fontFaces]]
1243
+ table as follows:
1209
1244
 
1210
1245
  [[theme.fontFaces]]
1211
1246
  family = "font_name"
1212
1247
  url = "app/static/font_file.woff"
1213
- weight = 400
1248
+ weight = "400"
1214
1249
  style = "normal"
1215
1250
  """,
1216
1251
  )
@@ -1227,9 +1262,10 @@ _create_theme_options(
1227
1262
  - "medium"
1228
1263
  - "large"
1229
1264
  - "full"
1230
- - ...or the number in pixels or rem. For example, you can use "10px",
1231
- "0.5rem", or "2rem". To follow best practices, use rem instead of
1232
- pixels when specifying a numeric size.
1265
+ - The number in pixels or rem.
1266
+
1267
+ For example, you can use "10px", "0.5rem", or "2rem". To follow best
1268
+ practices, use rem instead of pixels when specifying a numeric size.
1233
1269
  """,
1234
1270
  )
1235
1271
 
@@ -1245,9 +1281,12 @@ _create_theme_options(
1245
1281
  - "medium"
1246
1282
  - "large"
1247
1283
  - "full"
1248
- - ...or the number in pixels or rem. For example, you can use "10px",
1249
- "0.5rem", or "2rem". To follow best practices, use rem instead of
1250
- pixels when specifying a numeric size.
1284
+ - The number in pixels or rem.
1285
+
1286
+ For example, you can use "10px", "0.5rem", or "2rem". To follow best
1287
+ practices, use rem instead of pixels when specifying a numeric size.
1288
+
1289
+ If no button radius is set, Streamlit uses `theme.baseRadius` instead.
1251
1290
  """,
1252
1291
  )
1253
1292
 
@@ -1264,6 +1303,9 @@ _create_theme_options(
1264
1303
  categories=["theme", CustomThemeCategories.SIDEBAR],
1265
1304
  description="""
1266
1305
  The color of the border around dataframes and tables.
1306
+
1307
+ If no dataframe border color is set, Streamlit uses `theme.borderColor`
1308
+ instead.
1267
1309
  """,
1268
1310
  )
1269
1311
 
@@ -41,7 +41,6 @@ from typing_extensions import TypeAlias, TypeGuard
41
41
  from streamlit import config, errors, logger, string_util
42
42
  from streamlit.type_util import (
43
43
  CustomDict,
44
- NumpyShape,
45
44
  has_callable_attr,
46
45
  is_custom_dict,
47
46
  is_dataclass_instance,
@@ -924,7 +923,7 @@ def convert_anything_to_list(obj: OptionSequence[V_co]) -> list[V_co]:
924
923
 
925
924
  if isinstance(obj, (str, int, float, bool)):
926
925
  # Wrap basic objects into a list
927
- return [obj]
926
+ return [obj] # type: ignore[list-item]
928
927
 
929
928
  if isinstance(obj, EnumMeta):
930
929
  # Support for enum classes. For string enums, we return the string value
@@ -1167,7 +1166,7 @@ def determine_data_format(input_data: Any) -> DataFormat:
1167
1166
  if isinstance(input_data, pd.DataFrame):
1168
1167
  return DataFormat.PANDAS_DATAFRAME
1169
1168
  if isinstance(input_data, np.ndarray):
1170
- if len(cast("NumpyShape", input_data.shape)) == 1:
1169
+ if len(input_data.shape) == 1:
1171
1170
  # For technical reasons, we need to distinguish one
1172
1171
  # one-dimensional numpy array from multidimensional ones.
1173
1172
  return DataFormat.NUMPY_LIST
@@ -66,13 +66,15 @@ class AlertMixin:
66
66
  Thumb Up icon. Find additional icons in the `Material Symbols \
67
67
  <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
68
68
  font library.
69
- width : int or "stretch"
70
- The desired width of the alert expressed in pixels. If this is
71
- ``"stretch"`` (default), Streamlit sets the width of the alert to
72
- match the width of the parent container. Otherwise, this must be an
73
- integer. If the specified width is greater than the width of the
74
- parent container, Streamlit sets the width of the alert to match
75
- the width of the parent container.
69
+ width : "stretch" or int
70
+ The width of the alert element. This can be one of the following:
71
+
72
+ - ``"stretch"`` (default): The width of the element matches the
73
+ width of the parent container.
74
+ - An integer specifying the width in pixels: The element has a
75
+ fixed width. If the specified width is greater than the width of
76
+ the parent container, the width of the element matches the width
77
+ of the parent container.
76
78
 
77
79
  Example
78
80
  -------
@@ -137,13 +139,15 @@ class AlertMixin:
137
139
  Thumb Up icon. Find additional icons in the `Material Symbols \
138
140
  <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
139
141
  font library.
140
- width : int or "stretch"
141
- The desired width of the alert expressed in pixels. If this is
142
- ``"stretch"`` (default), Streamlit sets the width of the alert to
143
- match the width of the parent container. Otherwise, this must be an
144
- integer. If the specified width is greater than the width of the
145
- parent container, Streamlit sets the width of the alert to match
146
- the width of the parent container.
142
+ width : "stretch" or int
143
+ The width of the warning element. This can be one of the following:
144
+
145
+ - ``"stretch"`` (default): The width of the element matches the
146
+ width of the parent container.
147
+ - An integer specifying the width in pixels: The element has a
148
+ fixed width. If the specified width is greater than the width of
149
+ the parent container, the width of the element matches the width
150
+ of the parent container.
147
151
 
148
152
  Example
149
153
  -------
@@ -207,13 +211,15 @@ class AlertMixin:
207
211
  Thumb Up icon. Find additional icons in the `Material Symbols \
208
212
  <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
209
213
  font library.
210
- width : int or "stretch"
211
- The desired width of the alert expressed in pixels. If this is
212
- ``"stretch"`` (default), Streamlit sets the width of the alert to
213
- match the width of the parent container. Otherwise, this must be an
214
- integer. If the specified width is greater than the width of the
215
- parent container, Streamlit sets the width of the alert to match
216
- the width of the parent container.
214
+ width : "stretch" or int
215
+ The width of the info element. This can be one of the following:
216
+
217
+ - ``"stretch"`` (default): The width of the element matches the
218
+ width of the parent container.
219
+ - An integer specifying the width in pixels: The element has a
220
+ fixed width. If the specified width is greater than the width of
221
+ the parent container, the width of the element matches the width
222
+ of the parent container.
217
223
 
218
224
  Example
219
225
  -------
@@ -278,13 +284,15 @@ class AlertMixin:
278
284
  Thumb Up icon. Find additional icons in the `Material Symbols \
279
285
  <https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded>`_
280
286
  font library.
281
- width : int or "stretch"
282
- The desired width of the alert expressed in pixels. If this is
283
- ``"stretch"`` (default), Streamlit sets the width of the alert to
284
- match the width of the parent container. Otherwise, this must be an
285
- integer. If the specified width is greater than the width of the
286
- parent container, Streamlit sets the width of the alert to match
287
- the width of the parent container.
287
+ width : "stretch" or int
288
+ The width of the success element. This can be one of the following:
289
+
290
+ - ``"stretch"`` (default): The width of the element matches the
291
+ width of the parent container.
292
+ - An integer specifying the width in pixels: The element has a
293
+ fixed width. If the specified width is greater than the width of
294
+ the parent container, the width of the element matches the width
295
+ of the parent container.
288
296
 
289
297
  Example
290
298
  -------
@@ -645,7 +645,7 @@ class ArrowMixin:
645
645
  value_type="string_value",
646
646
  )
647
647
  self.dg._enqueue("arrow_data_frame", proto)
648
- return cast("DataframeState", widget_state.value)
648
+ return widget_state.value
649
649
  return self.dg._enqueue("arrow_data_frame", proto)
650
650
 
651
651
  @gather_metrics("table")
@@ -15,10 +15,9 @@
15
15
  from __future__ import annotations
16
16
 
17
17
  import re
18
- from typing import TYPE_CHECKING, cast
18
+ from typing import TYPE_CHECKING, Literal, cast
19
19
 
20
20
  from streamlit.elements.lib.layout_utils import (
21
- Height,
22
21
  LayoutConfig,
23
22
  WidthWithoutContent,
24
23
  validate_height,
@@ -41,7 +40,7 @@ class CodeMixin:
41
40
  *,
42
41
  line_numbers: bool = False,
43
42
  wrap_lines: bool = False,
44
- height: Height = "content",
43
+ height: int | Literal["content"] | None = "content",
45
44
  width: WidthWithoutContent = "stretch",
46
45
  ) -> DeltaGenerator:
47
46
  """Display a code block with optional syntax highlighting.
@@ -69,16 +68,31 @@ class CodeMixin:
69
68
  An optional boolean indicating whether to wrap lines. This defaults
70
69
  to ``False``.
71
70
 
72
- height : int or None
73
- Desired height of the code block expressed in pixels. If ``height``
74
- is ``None`` (default), Streamlit sets the element's height to fit
75
- its content. Vertical scrolling within the element is enabled when
76
- the height does not accommodate all lines.
71
+ height : "content" or int
72
+ The height of the code block element. This can be one of the following:
73
+
74
+ - ``"content"`` (default): The height of the element matches the
75
+ height of its content.
76
+ - An integer specifying the height in pixels: The element has a
77
+ fixed height. If the content is larger than the specified
78
+ height, scrolling is enabled.
79
+
80
+ .. note::
81
+ Use scrolling containers sparingly. If you use scrolling
82
+ containers, avoid heights that exceed 500 pixels. Otherwise,
83
+ the scroll surface of the container might cover the majority of
84
+ the screen on mobile devices, which makes it hard to scroll the
85
+ rest of the app.
77
86
 
78
87
  width : "stretch" or int
79
- The width of the code block. This can be either:
80
- - "stretch" (default): The code block will stretch to fill the container width
81
- - An integer: The code block will have a fixed width in pixels
88
+ The width of the code block element. This can be one of the following:
89
+
90
+ - ``"stretch"`` (default): The width of the element matches the
91
+ width of the parent container.
92
+ - An integer specifying the width in pixels: The element has a
93
+ fixed width. If the specified width is greater than the width of
94
+ the parent container, the width of the element matches the width
95
+ of the parent container.
82
96
 
83
97
  Examples
84
98
  --------
@@ -118,7 +132,10 @@ class CodeMixin:
118
132
  code_proto.show_line_numbers = line_numbers
119
133
  code_proto.wrap_lines = wrap_lines
120
134
 
121
- validate_height(height, allow_content=True)
135
+ if height is None:
136
+ height = "content"
137
+ else:
138
+ validate_height(height, allow_content=True)
122
139
  validate_width(width)
123
140
  layout_config = LayoutConfig(height=height, width=width)
124
141
 
@@ -529,7 +529,7 @@ class PydeckMixin:
529
529
 
530
530
  self.dg._enqueue("deck_gl_json_chart", pydeck_proto)
531
531
 
532
- return cast("PydeckState", widget_state.value)
532
+ return widget_state.value
533
533
 
534
534
  return self.dg._enqueue("deck_gl_json_chart", pydeck_proto)
535
535
 
@@ -59,8 +59,14 @@ class HelpMixin:
59
59
  The object whose information should be displayed. If left
60
60
  unspecified, this call will display help for Streamlit itself.
61
61
  width : "stretch" or int
62
- The width of the help element. Can be "stretch" to fill the container
63
- width, or an integer to specify a fixed width in pixels.
62
+ The width of the help element. This can be one of the following:
63
+
64
+ - ``"stretch"`` (default): The width of the element matches the
65
+ width of the parent container.
66
+ - An integer specifying the width in pixels: The element has a
67
+ fixed width. If the specified width is greater than the width of
68
+ the parent container, the width of the element matches the width
69
+ of the parent container.
64
70
 
65
71
  Example
66
72
  -------
@@ -60,13 +60,15 @@ class ExceptionMixin:
60
60
  ----------
61
61
  exception : Exception
62
62
  The exception to display.
63
- width : int or "stretch"
64
- The desired width of the exception expressed in pixels. If this is
65
- ``"stretch"`` (default), Streamlit sets the width of the exception
66
- to match the width of the parent container. Otherwise, this must be
67
- an integer. If the specified width is greater than the width of the
68
- parent container, Streamlit sets the width of the exception to
69
- match the width of the parent container.
63
+ width : "stretch" or int
64
+ The width of the exception element. This can be one of the following:
65
+
66
+ - ``"stretch"`` (default): The width of the element matches the
67
+ width of the parent container.
68
+ - An integer specifying the width in pixels: The element has a
69
+ fixed width. If the specified width is greater than the width of
70
+ the parent container, the width of the element matches the width
71
+ of the parent container.
70
72
 
71
73
  Example
72
74
  -------