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

Skip to content

Conversation

@sfc-gh-pchiu
Copy link
Contributor

@sfc-gh-pchiu sfc-gh-pchiu commented Mar 26, 2025

Describe your changes

Now with the ability to configure border radius via baseRadius theming config, there are a few places that would have issues with padding when the radius is set to fully rounded.

Testing Plan

  • E2E Tests

Manual Tests

import streamlit as st

st.date_input("Date Input", label_visibility="collapsed")
st.text_input("Text Input", value="Test", label_visibility="collapsed")
st.number_input("Number Input", label_visibility="collapsed")
st.selectbox("Selectbox", options=["Test"], label_visibility="collapsed")
st.time_input("Time Input", label_visibility="collapsed")
st.text_area("Text Area", value="Test", label_visibility="collapsed")
st.container().chat_input("Chat Input")
default full none
Screenshot 2025-03-26 at 4 32 51 PM Screenshot 2025-03-26 at 4 32 44 PM Screenshot 2025-03-26 at 4 28 02 PM

Note: Value element in st.time_input has a 2px left margin


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 Mar 26, 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 Mar 26, 2025

✅ PR preview is ready!

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

@sfc-gh-pchiu sfc-gh-pchiu added security-assessment-completed Security assessment has been completed for PR change:feature PR contains new feature or enhancement implementation impact:users PR changes affect end users labels Mar 26, 2025
@sfc-gh-pchiu sfc-gh-pchiu force-pushed the advanced-theming/rounded-input-left-padding branch from a9e0606 to ff2620a Compare March 26, 2025 20:49
@sfc-gh-pchiu sfc-gh-pchiu changed the title Advanced theming/rounded input left padding [theming] Fine tune element spacing for baseRadius config Mar 26, 2025
@sfc-gh-pchiu sfc-gh-pchiu requested a review from Copilot March 26, 2025 21:05
Copy link
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 fine tunes element spacing for the baseRadius configuration across various widgets and components. The changes update destructuring in TextInput and adjust padding and font size values in TextInput, NumberInput, ArrowTable, BaseWidget, and ChatInput to better reflect the new theming guidelines.

Reviewed Changes

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

Show a summary per file
File Description
frontend/lib/src/components/widgets/TextInput/TextInput.tsx Updated destructuring to include icon and maxChars; updated references to use these variables.
frontend/lib/src/components/widgets/NumberInput/NumberInput.tsx Adjusted left padding from theme.spacing.sm to theme.spacing.md.
frontend/lib/src/components/elements/ArrowTable/styled-components.ts Added left padding for header cells.
frontend/lib/src/components/widgets/BaseWidget/styled-components.ts Changed right positioning from a calculation based on theme.fontSizes.sm to theme.fontSizes.mdLg.
frontend/lib/src/components/widgets/ChatInput/ChatInput.tsx Modified left padding from theme.spacing.none to theme.spacing.twoXS.
Comments suppressed due to low confidence (4)

frontend/lib/src/components/widgets/BaseWidget/styled-components.ts:57

  • Ensure that 'theme.fontSizes.mdLg' is a valid and intended property in your theme. If this is a new addition, please confirm that it aligns with the design specifications.
right: `calc(${theme.fontSizes.mdLg} * 0.5)`

frontend/lib/src/components/widgets/NumberInput/NumberInput.tsx:423

  • [nitpick] Confirm that 'theme.spacing.md' provides the appropriate padding for NumberInput as compared to the previous value (theme.spacing.sm). Verify against design guidelines if this change might affect overall layout consistency.
paddingLeft: theme.spacing.md,

frontend/lib/src/components/elements/ArrowTable/styled-components.ts:80

  • [nitpick] Ensure that adding left padding to header cells does not cause unintended alignment issues in the table layout. It may be worthwhile to review adjacent cell padding for consistent spacing.
paddingLeft: theme.spacing.sm,

frontend/lib/src/components/widgets/ChatInput/ChatInput.tsx:488

  • [nitpick] Verify that 'theme.spacing.twoXS' offers the intended spacing for ChatInput. Compare this adjustment with similar components to ensure uniformity in spacing across the UI.
paddingLeft: theme.spacing.twoXS,

@sfc-gh-pchiu sfc-gh-pchiu marked this pull request as ready for review March 26, 2025 21:41
@lukasmasuch
Copy link
Collaborator

lukasmasuch commented Mar 26, 2025

I think we need to go through all input field widgets and make sure they all have the same left padding and all the text values are starting at the same position:

import streamlit as st

st.date_input("Date Input", label_visibility="collapsed")
st.text_input("Text Input", value="Test", label_visibility="collapsed")
st.number_input("Number Input", label_visibility="collapsed")
st.selectbox("Selectbox", options=["Test"], label_visibility="collapsed")
st.time_input("Time Input", label_visibility="collapsed")
st.text_area("Text Area", value="Test", label_visibility="collapsed")
st.container().chat_input("Chat Input")

Also, I think the spacing.lg of text_input looks a bit too much. I think the spacing.md of number input seems better with our default rounding.

@sfc-gh-pchiu sfc-gh-pchiu force-pushed the advanced-theming/rounded-input-left-padding branch from ff2620a to 6cf4284 Compare March 26, 2025 23:33
@sfc-gh-pchiu
Copy link
Contributor Author

Added screenshots of all input widgets under Manual Tests

Copy link
Collaborator

@lukasmasuch lukasmasuch Mar 27, 2025

Choose a reason for hiding this comment

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

I think the chat input padding is too much, the full left padding of chat input is at 1.25rem while other widgets only have a padding of 0.75rem. I think it's better to keep this at none and instead overwrite the radius properties in Root with:

borderTopLeftRadius: "0",
borderTopRightRadius: "0",
borderBottomLeftRadius: "0",
borderBottomRightRadius: "0",

since the additional radius isn't required.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay I see, yeah I think it is better to not add more padding if it's just for the cursor. But this fixed the issue with hidden cursor.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think changing the border radius to 0 of the inner text area root will also fix the hidden cursor issue

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah sorry, I just meant to confirm that your fix setting the border radius to 0 made it so that we don't need the additional padding (which was not ideal in the first place) 👍

@lukasmasuch
Copy link
Collaborator

The padding for text area seems to be a bit to large (1rem vs 0.75rem), I think we can just update this to spacing.md to be more consistent:

paddingRight: theme.spacing.md,
paddingLeft: theme.spacing.md,
paddingBottom: theme.spacing.md,
paddingTop: theme.spacing.md,

And for Input instruction it still feels slightly to close, I think this small tweak on bottom in StyledWidgetInstructions could help:

 bottom: theme.spacing.threeXS,

@sfc-gh-pchiu sfc-gh-pchiu force-pushed the advanced-theming/rounded-input-left-padding branch from ac73a6f to ddb5270 Compare March 27, 2025 20:13
Copy link
Collaborator

@lukasmasuch lukasmasuch left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@sfc-gh-pchiu sfc-gh-pchiu merged commit e3eadd7 into develop Mar 27, 2025
33 checks passed
@sfc-gh-pchiu sfc-gh-pchiu deleted the advanced-theming/rounded-input-left-padding branch March 27, 2025 21:58
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.

3 participants