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

Allow currency format for dcc.Input of type='number' #2329

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

Allow currency format for dcc.Input of type='number' #2329

celia-lm opened this issue Nov 21, 2022 · 0 comments
Labels
feature something new P3 backlog

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:

[email protected]_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)

@gvwilson gvwilson self-assigned this Jul 24, 2024
@gvwilson gvwilson removed their assignment Aug 2, 2024
@gvwilson gvwilson added P3 backlog feature something new labels Aug 13, 2024
@gvwilson gvwilson changed the title [Feature Request] Allow currency format for dcc.Input of type='number' Allow currency format for dcc.Input of type='number' Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new P3 backlog
Projects
None yet
Development

No branches or pull requests

2 participants