Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jrieke
Copy link
Collaborator

@jrieke jrieke commented Jun 25, 2025

Describe your changes

Allow using Markdown in the title of st.dialog. This uses the same restrictions as Markdown labels, i.e. certain elements like tables or bullet points are not allowed.

Screenshot 2025-06-26 at 00 24 41

Also fixes an issue where long dialog titles can touch the X icon on the right side by adding a right margin to the title:

Screenshot 2025-06-26 at 02 13 48

GitHub Issue Link (if applicable)

Closes #11755

Testing Plan

  • Added st.dialog to the e2e tests for Markdown features.
  • Added a snapshot e2e test for long dialog titles.

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@snyk-io
Copy link
Contributor

snyk-io bot commented Jun 25, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

@github-actions
Copy link
Contributor

github-actions bot commented Jun 25, 2025

✅ PR preview is ready!

Name Link
📦 Wheel file https://core-previews.s3-us-west-2.amazonaws.com/pr-11763/streamlit-1.46.0-py3-none-any.whl
🕹️ Preview app pr-11763.streamlit.app (☁️ Deploy here if not accessible)

@jrieke jrieke added security-assessment-completed Security assessment has been completed for PR impact:users PR changes affect end users change:feature PR contains new feature or enhancement implementation labels Jun 25, 2025
@jrieke jrieke changed the title Add Markdown support to st.dialog title [WIP] Add Markdown support to st.dialog title Jun 25, 2025
isCaption: boolean
isInSidebarOrDialog: boolean
isLabel?: boolean
isDialogTitle?: boolean
Copy link
Collaborator Author

@jrieke jrieke Jun 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a huge fan of adding isDialogTitle here just because we already have so many different flags + it becomes pretty messy to set the styles below. But every alternative would require a bigger refactoring in my eyes, which should probably be done separately.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that we can't use isLabel because it would overwrite the font size and weight of the dialog title.

Copy link
Collaborator

@lukasmasuch lukasmasuch Jun 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, maybe an alternative is a new a bit more generic inheritFont flag, which makes sure that it inherits all relevant font settings. And then we can use isLabel(to restrict some features) + inheritFont to make sure that the parent font settings are used.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm yeah that's a good idea. It's still not great and we should definitely refactor this at some point, but maybe good enough for now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented ✅

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, markdown got quite messy over time :(

@jrieke jrieke changed the title [WIP] Add Markdown support to st.dialog title Add Markdown support to st.dialog title Jun 26, 2025
@jrieke jrieke marked this pull request as ready for review June 26, 2025 00:27
Copy link
Collaborator

@sfc-gh-lmasuch sfc-gh-lmasuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍



@st.dialog(
"This is a very long dialog title that should not overlap with the close button"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: not super necessary since markdown_features should do the job, but you could place a few markdown elements in this long title

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I thought about this but wanted to keep it out so it's clear why it fails.

@jrieke jrieke merged commit 0340b4b into develop Jun 26, 2025
37 checks passed
@jrieke jrieke deleted the feature/markdown-dialog-title branch June 26, 2025 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:feature PR contains new feature or enhancement implementation impact:users PR changes affect end users security-assessment-completed Security assessment has been completed for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Markdown support for st.dialog title

4 participants