# Combining value and placeholder in dcc.Input field

**URL:** <https://community.plotly.com/t/combining-value-and-placeholder-in-dcc-input-field/43609>\
**Category:** Dash Python\
**Created:** [August 10, 2020, 8:59am UTC](https://community.plotly.com/t/combining-value-and-placeholder-in-dcc-input-field/43609 "2020-08-10T08:59:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![NRVA](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/nrva/32/10795_2.png) [@NRVA](https://community.plotly.com/u/NRVA)\
**Post date:** [August 10, 2020, 8:59am UTC](https://community.plotly.com/t/combining-value-and-placeholder-in-dcc-input-field/43609/1 "2020-08-10T08:59:15Z")

</div>

I have a input field with a placeholder describing the input, but I also want an initial value (zero) in the output while the user sees the placeholder.

If I add a value=0 the placeholder does not show (but I want the placeholder to show in the field).

```auto
import dash_html_components as html
import dash
import dash_core_components as dcc
from dash.dependencies import Input, Output

app = dash.Dash( __name__ )

app.layout = html.Div([
    html.Div([dcc.Input(id='my-input', placeholder="write a number", type="number")]),
    html.Br(),
    html.Div(id='my-output')
])

@app.callback(Output("my-output", "children"), 
              [Input("my-input", "value")])

def output_text(value):
    #0 if value == None else value
    
    return html.Div(html.H6(value))

if __name__ == " __main__":
    app.run_server(debug=True)

```

S if you run the script above I want 0 to show before the user types a number.

How can I solve this?

---

<div class="post-metadata">

**Author:** ![Emil](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/emil/32/31734_2.png) [@Emil](https://community.plotly.com/u/Emil)\
**Post date:** [August 10, 2020, 9:21am UTC](https://community.plotly.com/t/combining-value-and-placeholder-in-dcc-input-field/43609/2 "2020-08-10T09:21:03Z")

</div>

Commenting in the line you have commented out, it works as intended?

```auto
import dash_html_components as html
import dash
import dash_core_components as dcc
from dash.dependencies import Input, Output

app = dash.Dash( __name__ )
app.layout = html.Div([
    html.Div([dcc.Input(id='my-input', placeholder="write a number", type="number")]),
    html.Br(),
    html.Div(id='my-output')
])

@app.callback(Output("my-output", "children"),
              [Input("my-input", "value")])
def output_text(value):
    value = 0 if value is None else value
    return html.Div(html.H6(value))

if __name__ == " __main__":
    app.run_server(debug=True)

```
