Skip to content

Conversation

@sfc-gh-lwilby
Copy link
Collaborator

Describe your changes

Fixes pills and segmented control buttons wrapping unexpectedly when using content width.

Changes Made:

  • Changed maxWidth to be conditional: "100%" for stretch width, "fit-content" for content width
  • Resolves flexbox width miscalculation that caused the last button to wrap

GitHub Issue Link

Fixes #12067

Testing Plan

  • E2E Tests (added regression test with pills at app start)
  • Manual testing completed (verified content and stretch widths work correctly)

Additional Notes:

The bug was caused by commit 32a82fa204 which changed maxWidth from "fit-content" to "100%" for all modes. For content-width button groups, maxWidth: "100%" causes flexbox to miscalculate the container width, making the last button wrap to a new line. The fix makes maxWidth conditional to support both content and stretch widths properly.


Contribution License Agreement

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

@sfc-gh-lwilby sfc-gh-lwilby added security-assessment-completed Security assessment has been completed for PR change:bugfix PR contains bug fix implementation impact:users PR changes affect end users labels Nov 7, 2025
@snyk-io
Copy link
Contributor

snyk-io bot commented Nov 7, 2025

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

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 7, 2025

✅ PR preview is ready!

Name Link
📦 Wheel file https://core-previews.s3-us-west-2.amazonaws.com/pr-12969/streamlit-1.51.0-py3-none-any.whl
📦 @streamlit/component-v2-lib Download from artifacts
🕹️ Preview app pr-12969.streamlit.app (☁️ Deploy here if not accessible)

@sfc-gh-lwilby sfc-gh-lwilby changed the title Fix st.pills and st.segmented_control wrapping regression [fix] st.pills and st.segmented_control wrapping regression Nov 7, 2025
@sfc-gh-lwilby sfc-gh-lwilby marked this pull request as ready for review November 8, 2025 15:24
@sfc-gh-lwilby sfc-gh-lwilby merged commit 287de8b into develop Nov 8, 2025
39 of 40 checks passed
@sfc-gh-lwilby sfc-gh-lwilby deleted the fix/pills-wrapping-regression branch November 8, 2025 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:bugfix PR contains bug fix 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.

st.pills incorrectly adding line breaks on the last option (if the a previous pill above it has exactly 1 option)

3 participants