Skip to content

Pills do not show selected value(s) if disabled #12388#12555

Merged
sfc-gh-bnisco merged 17 commits intostreamlit:developfrom
davidsjoberg1:gh-12388
Sep 25, 2025
Merged

Pills do not show selected value(s) if disabled #12388#12555
sfc-gh-bnisco merged 17 commits intostreamlit:developfrom
davidsjoberg1:gh-12388

Conversation

@davidsjoberg1
Copy link
Copy Markdown
Contributor

@davidsjoberg1 davidsjoberg1 commented Sep 17, 2025

Describe your changes

Before the change, when disabling a st.pills component it turned into a faded gray color. The goal with the issue was to make still make it faded but keep the same colors as when not disabled.

In styled-components.ts for BaseButton there is a style called StyledButtonGroupBaseButton where the colors was set when a button is disabled. Instead of changing color I when disabling a button I just used opacity to make the faded look. Since StyledButtonGroupBaseButton is used in both st.pills and st.segmented_control this change will affect both of these components.

disabled=False

This is how it looks when the button is not disabled (just like before)

disabledfalse.mov

disabled=True

Before change:

before.mov

After change:

after.mov

GitHub Issue Link

Closes #12388

Testing Plan

I have made changes in e2e_playwright/st_pills_test.py and e2e_playwright/st_segmented_control_test.py.
I updated the disabled tests to expect opacity instead of negating an rgb(...) color, matching the new design.

  • Unit Tests (JS and Python) ✅
  • E2E Tests: st_segmented_control_test.py ✅
  • E2E Tests: st_pills_test.py ✅

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
Copy Markdown
Contributor

snyk-io bot commented Sep 17, 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)

@lukasmasuch lukasmasuch requested a review from Copilot September 19, 2025 12:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue where disabled pills and segmented controls would appear in faded gray colors, making it impossible to see selected values. The fix changes the disabled styling to use opacity instead of color changes, preserving the original colors while maintaining the disabled appearance.

  • Replaced disabled color styling with opacity-based styling in BaseButton components
  • Updated E2E tests to verify opacity instead of color absence for disabled states
  • Fixed visual feedback for both st.pills and st.segmented_control components

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
frontend/lib/src/components/shared/BaseButton/styled-components.ts Replaced disabled color styling with opacity to preserve original colors
e2e_playwright/st_segmented_control_test.py Updated test to check for opacity instead of color negation
e2e_playwright/st_pills_test.py Updated test to check for opacity instead of color negation

@lukasmasuch lukasmasuch added change:bugfix PR contains bug fix implementation impact:users PR changes affect end users status:needs-product-approval PR requires product approval before merging labels Sep 19, 2025
@jrieke
Copy link
Copy Markdown
Collaborator

jrieke commented Sep 21, 2025

Hey @davidsjoberg1! Good catch, thanks for the contribution! I agree we should change this, but I think we need a different approach than simply adding opacity, so this is more consistent with other widgets.

Importantly, the disabled pills/controls should 1) not have a hover effect and 2) be completely grayscale. (That's also what we do for all other widgets).

Maybe it would already be sufficient if you use a slightly gray background for the selected pills/controls instead of the current white?

@davidsjoberg1
Copy link
Copy Markdown
Contributor Author

davidsjoberg1 commented Sep 22, 2025

Hello @jrieke, thank you for the feedback!
I have now made some changes:

  1. The color for disabled pills/control now matches StyledPrimaryButton, to keep things consistent
  2. When a disabled pill/control is selected, the background color is gray30. Please let me know if you prefer another color!
  3. There is no hover effect
  4. The previous changes in the test files are reset

Below is a video of how the current implementation looks

after_feedback.mov

Please let me know if I need to make some changes, or if I missunderstood something :)

@jrieke
Copy link
Copy Markdown
Collaborator

jrieke commented Sep 22, 2025

Looks great! I think we should use a different color than gray30 to make this theme-aware. It seems like the tags in st.multiselect use theme.colors.fadedText05 for the background when disabled, I just tried this out locally and it looks pretty good, wdyt?

Screenshot 2025-09-22 at 20 19 34

@davidsjoberg1
Copy link
Copy Markdown
Contributor Author

I agree! I just pushed the change to fadedText05

@jrieke jrieke added status:product-approved Community PR is approved by product team security-assessment-completed and removed status:needs-product-approval PR requires product approval before merging labels Sep 23, 2025
@sfc-gh-bnisco
Copy link
Copy Markdown
Collaborator

Thanks for the contribution @davidsjoberg1!

Can you please add Snapshot tests for this case? I see that we already have a test case for disabled st.pills, but not for disabled st.pills with a selected value.

We have directions in our contributing wiki: https://github.com/streamlit/streamlit/wiki/Running-e2e-tests-and-updating-snapshots. Let me know if you have questions, thank you!

@davidsjoberg1
Copy link
Copy Markdown
Contributor Author

Hello @sfc-gh-bnisco!
I just added a test for disabled-selected pills. I basically copied the test for disabled but with the disabled-selected st.pills. I added the disabled-selected st.pills in the end of st_pills.py. It would make sense to put this after the disabled st.pills, however then I need to change all indexes in st_pills_test.py. Do you want me to make this change or is it ok with the current one?

@sfc-gh-bnisco
Copy link
Copy Markdown
Collaborator

Thanks for checking @davidsjoberg1 , that's a really thoughtful question! The way you handled it is nice and pragmatic!

Long-term we are moving our tests away from the index-based paradigm anyway, but this test suite hasn't yet been updated. We are good to leave this as-is!

@sfc-gh-bnisco sfc-gh-bnisco merged commit a348ed3 into streamlit:develop Sep 25, 2025
36 checks passed
@jrieke
Copy link
Copy Markdown
Collaborator

jrieke commented Sep 30, 2025

@davidsjoberg1 Congrats on getting this merged! 🥳 We'd love to send you some swag as a little thank you, just fill out this form and we'll get it on the way: https://docs.google.com/forms/d/e/1FAIpQLSe7cXh3H1DmrgNpVew9qViGIHX7vdEbTv5isA44_z5bgaKTKg/viewform

@davidsjoberg1
Copy link
Copy Markdown
Contributor Author

@jrieke Nice, thank you!

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 status:product-approved Community PR is approved by product team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pills do not show selected value(s) if disabled

5 participants