Checklist not working?

I am trying to use checklists but I keep getting errors. I first tried adding

dcc.Checklist(['New York City', 'Montréal', 'San Francisco'], ['Montréal', 'San Francisco'])

and the page in my local server stops rendering. I get the error

TypeError: id prop must be a string or dict, not ['New York City', 'Montréal', 'San Francisco'].

So I add labels, such as

dcc.Checklist(options = ['New York City', 'Montréal', 'San Francisco'], value = ['Montréal', 'San Francisco']).

Now the page renders but I get the error:

Invalid argument `options[0]` passed into Checklist.
Expected `object`.
Was supplied type `string`.

I then tried it in a separate py script with the code exactly as it is in the dcc documentation and I’m still getting these errors.

from dash import Dash, dcc, html

app = Dash(__name__)

app.layout = html.Div([
    dcc.Checklist(options = ['New York City', 'Montréal', 'San Francisco'],
                  value = ['Montréal', 'San Francisco'])

if __name__ == '__main__':

Does anyone know what’s going on? I’ve cleared my cookies and cache. I’ve done hard reloads, and restarted my computer, so I don’t think it’s anything on my end, but I could be wrong. Thanks!

1 Like

Hi @dashls and welcome to the dash community :slight_smile:

The documentation is based on the most recent version of Dash. This new more concise syntax is new in version 2.1.0. You can see more information in the announcement 📣 Dash 2.1.0 Released -

1 Like

Thanks for this! So does this mean that I have to update the Dash package? I’m guessing I would also have to review my old code to change it to the new format?

The new version is backwards compatible, so the “old” way is still valid. When you upgrade you’ll also be able to use the new (better) way.

Happy coding :slight_smile:

Great to hear. Thanks!