Allow currency format for dcc.Input of type='number'
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 24.4k
- Forks
- 2.3k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 13
Description
Describe the solution you'd like
Allow currency format for dcc.Input while keeping the value type as number and the arrows to increase/decrease it.
Describe alternatives you've considered
Clientside circular callback that updates the value format based on this JS solution:
import dash
from dash import Input, Output, State, callback, dcc, html, ctx
app = dash.Dash(__name__)
app.layout = html.Div([
dcc.Input(id='input-number', value=522.31, type='number')
])
app.clientside_callback(
"""
function(value) {
return value.toLocaleString('us-US', { style: 'currency', currency: 'USD' });
}
""",
Output('input-number', 'value'),
Input('input-number', 'value')
)
if __name__ == '__main__':
app.run_server(debug=True)
It raises this error in the JS Console:
react-dom@16.v2_7_0m1667919873.14.0.js:1857 The specified value "-US$1.00" cannot be parsed, or is out of range.
If type='number' is not specified, the value is accepted but the arrows to increase/decrease the value disappear.
Other option is a one-cell table with html.Buttons and a callback to increase/decrease the value (it's very complex for just a simple input)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the dcc.Input implementation and its number-type behavior, then review how formatting and increment/decrement controls are handled. The issue is done when a currency-formatted input preserves a numeric value and retains the arrows, with the behavior covered by the relevant input tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, python, react
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100