Skip to content

Commit 29a1c66

Browse files
authored
fix(MarkdownStream): width and height are now respected; set a maximum width of 680px with auto margins (#1944)
1 parent 4a9ea3f commit 29a1c66

File tree

5 files changed

+14
-5
lines changed

5 files changed

+14
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020

2121
* The `.get_latest_stream_result()` method on `ui.MarkdownStream()` was deprecated in favor of the new `.latest_stream` property. Call `.result()` on the property to get the latest result, `.status` to check the status, and `.cancel()` to cancel the stream.
2222

23+
* `MarkdownStream()` now has a default maximum width of `680px` for better readability. Also, similar to `Chat()`, it now also horizontally centers itself. (#1944)
24+
2325
* `ui.page_navbar()` and `ui.navset_bar()` now correctly apply `theme` and additional attributes from `navbar_options` created with `ui.navbar_options()`. (#1942)
2426

2527
### Bug fixes
@@ -28,6 +30,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2830

2931
* Fixed an issue where the `.update_user_input()` method on `ui.Chat()` isn't working in shinylive. (#1891)
3032

33+
* Fixed an issue where `width` and `height` on `MarkdownStream()` were not working as intended. (#1944)
34+
3135
* Fixed an issue with the `.click()` method on InputActionButton controllers in `shiny.playwright.controllers` where the method would not work as expected. (#1886)
3236

3337
## [1.3.0] - 2025-03-03

js/markdown-stream/markdown-stream.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
@include highlight_styles.atom_one_dark;
77
}
88

9+
shiny-markdown-stream {
10+
display: block;
11+
}
12+
913
/*
1014
Styling for the code-copy button (inspired by Quarto's code-copy feature)
1115
*/

shiny/ui/_markdown_stream.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def ui(
271271
content: TagChild = "",
272272
content_type: StreamingContentType = "markdown",
273273
auto_scroll: bool = True,
274-
width: CssUnit = "100%",
274+
width: CssUnit = "min(680px, 100%)",
275275
height: CssUnit = "auto",
276276
) -> Tag:
277277
"""
@@ -320,7 +320,7 @@ def output_markdown_stream(
320320
content: TagChild = "",
321321
content_type: StreamingContentType = "markdown",
322322
auto_scroll: bool = True,
323-
width: CssUnit = "100%",
323+
width: CssUnit = "min(680px, 100%)",
324324
height: CssUnit = "auto",
325325
) -> Tag:
326326
"""
@@ -369,6 +369,7 @@ def output_markdown_stream(
369369
"style": css(
370370
width=as_css_unit(width),
371371
height=as_css_unit(height),
372+
margin="0 auto",
372373
),
373374
"content-type": content_type,
374375
"auto-scroll": "" if auto_scroll else None,

shiny/www/py-shiny/markdown-stream/markdown-stream.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)