Skip to content
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

[Feature Request] Allow currency format for dcc.Input of type='number' #2329

Open
celia-lm opened this issue Nov 21, 2022 · 0 comments
Open

Comments

@celia-lm
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant