简体   繁体   中英

Plotly Dash center dcc.Input text field

I'm having a lot of difficulties figuring out what style parameters are required to center a dash_core_components.Input text field in the middle of my page.

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

text_input_style = {'justify-content': 'center', 'align-items': 'center'}
bucket_select = html.Div([
    html.Label('S3 bucket:'),
    dcc.Input(id='bucket_name', placeholder='Enter input here...', 
              value=None, type='text', 
              style={'width': '10%', 'textAlign': 'center'}),
    html.Div(id='bucket_out')
], style=text_input_style)

app = dash.Dash(__name__)
app.layout = html.Div(bucket_select)
app.run_server(port=5555)

So far I've tried:

  • 'justify-content': 'center'
  • 'align-items': 'center'
  • 'display': 'flex'
  • 'padding-left':'45%'

I've tried searching the documentation for dcc.Input , but I can't find any style information.

This is where you can find the various props for dcc.Input . You can set the containing div to have display='flex' and justifyContent='center' . Example:

html.Div(
    children=[dcc.Input()],  # fill out your Input however you need
    style=dict(display='flex', justifyContent='center')
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM