How to add title for dcc.RadioItems

图片

Hi, does anyone can help me on how to add the title in the red box as the pic showed. I want to keep the current style for RadioItems, but when I try to add ‘title’ in my code comment line#title here, it reports an error “ NameError: name ‘sen_layout’ is not defined”.

Here is my code:

sen_layout = html.Div([
html.Div(
#title here
dcc.RadioItems(
id=str(scenarios[0]),
options=[{‘label’: i, ‘value’: i} for i in [‘No US’, ‘US Cont’,‘US 50%’]],
value=‘No US’,
)
,style={‘width’: ‘5%’, ‘display’: ‘inline-block’}
),

                  html.Div(
                  dcc.RadioItems(
                                      id=str(scenarios[1]),
                                      options=[{'label': i, 'value': i} for i in ['No US', 'US Cont','US 50%']],
                                      value='No US',
                                  )
                   ,style={'width': '5%', 'display': 'inline-block'}
                   ), 
                  
                  html.Div( 
                  dcc.RadioItems(
                                      id=str(scenarios[2]),
                                      options=[{'label': i, 'value': i} for i in ['No US', 'US Cont','US 50%']],
                                      value='No US', 
                                  ),style={'width': '5%', 'display': 'inline-block'}
                  ),
                     
              ])

Problem solved, need a inside the html.Div() and move style after the ]. New code here:

sen_layout = html.Div([

                  html.Div([scenarios[0], 
                      
                  dcc.RadioItems(
                                      id=str(scenarios[0]),
                                      options=[{'label': i, 'value': i} for i in ['No US', 'US Cont','US 50%']],
                                      value='No US',
                                      
                                  )
                  
                  ],style={'width': '5%', 'display': 'inline-block'}), 
                  
                  html.Div([scenarios[1],
                  dcc.RadioItems(
                                      id=str(scenarios[1]),
                                      options=[{'label': i, 'value': i} for i in ['No US', 'US Cont','US 50%']],
                                      value='No US',
                                     
                                  )
                   
                   ],style={'width': '5%', 'display': 'inline-block'}), 
                  
                  html.Div([scenarios[2], 
                  dcc.RadioItems(
                                      id=str(scenarios[2]),
                                      options=[{'label': i, 'value': i} for i in ['No US', 'US Cont','US 50%']],
                                      value='No US',
                                      #style={'width': '5%', 'display': 'inline-block'},
                                      #labelStyle={'width': '5%', 'display': 'inline-block'}
                                  )
                  ],style={'width': '5%', 'display': 'inline-block'}),
                     
              ])