-
Notifications
You must be signed in to change notification settings - Fork 4k
Allow configuring delta arrow in st.metric
#12982
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
✅ PR preview is ready!
|
There was a problem hiding this 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 adds a new delta_arrow parameter to the st.metric component, allowing users to manually control the direction of the delta indicator arrow independently from the delta value's sign.
Key changes:
- Introduces
delta_arrowparameter with values "auto" (default), "up", "down", and "off" - When set, overrides the automatic arrow direction that normally follows the delta sign
- Adjusts frontend padding to account for the arrow's visibility
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
lib/streamlit/elements/metric.py |
Adds delta_arrow parameter, validation, and logic to override direction proto |
lib/tests/streamlit/elements/metric_test.py |
Adds unit tests for default behavior, valid values, and invalid input |
frontend/lib/src/components/elements/Metric/Metric.tsx |
Passes showArrow prop based on whether direction is null |
frontend/lib/src/components/elements/Metric/styled-components.ts |
Adjusts padding conditionally based on arrow visibility |
e2e_playwright/st_metric.py |
Adds test cases demonstrating arrow override scenarios |
e2e_playwright/st_metric_test.py |
Adds E2E tests verifying arrow behavior and snapshot comparison |
frontend/lib/src/components/elements/Metric/styled-components.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <[email protected]>
|
@jrieke regarding the |
Yeah I've been thinking about this too. I think I'm slightly in favor of using |
e2e_playwright/__snapshots__/linux/st_metric_test/st_metric-border[dark_theme-chromium].png
Show resolved
Hide resolved
sfc-gh-nbellante
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool feature!
Describe your changes
Adds a
delta_arrow: "auto" | "up" | "down" | "off"parameter tost.metricthat allows to configure the delta arrow direction.GitHub Issue Link (if applicable)
st.metric#4775Testing Plan
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.