---
title: "#30DaysOfStreamlit Day11 st.multiselect"
description: "この記事では、#30DaysOfStreamlitの内容の紹介を行います。\nst.multiselect\n`st.multiselect`は複数選択のウィジェットを実装する関数です。"
image: https://knowledge.insight-lab.co.jp/hubfs/30days_logo.png
---

[![INSIGHT LAB](https://knowledge.insight-lab.co.jp/hs-fs/hubfs/INSIGHT%20LAB_%E6%96%87%E5%AD%97%E3%81%AE%E3%81%BF_WHT-1.png?width=400&height=110&name=INSIGHT%20LAB_%E6%96%87%E5%AD%97%E3%81%AE%E3%81%BF_WHT-1.png) ![INSIGHT LAB](https://knowledge.insight-lab.co.jp/hs-fs/hubfs/INSIGHT%20LAB_%E6%96%87%E5%AD%97%E3%81%AE%E3%81%BF.png?width=400&height=110&name=INSIGHT%20LAB_%E6%96%87%E5%AD%97%E3%81%AE%E3%81%BF.png)](https://knowledge.insight-lab.co.jp/aidx)

[![お問い合わせ](https://hubspot-no-cache-na2-prod.s3.amazonaws.com/cta/default/5935783/97d2baf6-f3cd-4932-be66-900264c5d298.png)](https://hubspot-cta-redirect-na2-prod.s3.amazonaws.com/cta/redirect/5935783/97d2baf6-f3cd-4932-be66-900264c5d298)

<https://knowledge.insight-lab.co.jp/aidx/30daysofstreamlit-day11-st.multiselect#tmpmodule_1593485625696253>

- [AIDXナレッジ](https://knowledge.insight-lab.co.jp/aidx)

###### 2 分で読むことができます。

# [#30DaysOfStreamlit Day11 st.multiselect](https://knowledge.insight-lab.co.jp/aidx/30daysofstreamlit-day11-st.multiselect)

 執筆者 [Budo Ogimoto](https://knowledge.insight-lab.co.jp/aidx/author/budo) 更新日時 2023年12月19日

###### Topics: [Python](https://knowledge.insight-lab.co.jp/aidx/tag/python) [streamlit](https://knowledge.insight-lab.co.jp/aidx/tag/streamlit)

![30DaysOfStreamlit Day11 st.multiselect](https://knowledge.insight-lab.co.jp/hubfs/30days_logo.png)

 目次

## はじめに

---

この記事では、#30DaysOfStreamlitの内容の紹介を行います。  
#30DaysOfStreamlitについては[コチラの記事](https://knowledge.insight-lab.co.jp/aidx/30daysofstreamlitをやってみた)を参照してください。

## st.multiselect

`st.multiselect`は複数選択のウィジェットを実装する関数です。

## 構築する目標

「Red」「Blue」「Green」「Yellow」の四色を複数選べるUIを実装します。   
また、以下のような仕様を含みます。

1. 選択した色が全て確認できる
2. 選択順に色にインデックスが振られる
3. 初期値は「Yellow」「Red」の順にしておく

## アプリケーションの構築

アプリケーションを構築していきます。  
コードは以下の通りです。

## コードの解説

まずは、必要なライブラリをインポートします。

続いてヘッダーテキストを設定します。

続いて、複数選択のウィジェットを実装します。

選択した結果は`options`に格納されます。   
また、最初の引数は選択肢の案内文で、次に選択可能な選択肢一覧、続いて初期値となります。  
最後に、`st.write`を利用して表示を行います。

この時、optionsには選択した順にリストで格納されています。 出力結果は以下の通りです。

![スクリーンショット 2023-07-18 4.42.33](https://knowledge.insight-lab.co.jp/hs-fs/hubfs/%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88%202023-07-18%204.42.33.png?width=1194&height=502&name=%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%BC%E3%83%B3%E3%82%B7%E3%83%A7%E3%83%83%E3%83%88%202023-07-18%204.42.33.png)

- [Tweet](https://twitter.com/share)

![Budo Ogimoto](https://knowledge.insight-lab.co.jp/hubfs/Budo.png)

#### 執筆者 [Budo Ogimoto](https://knowledge.insight-lab.co.jp/aidx/author/budo)

柔術を操るデータサイエンティスト

###### [前の投稿](https://knowledge.insight-lab.co.jp/aidx/30daysofstreamlit-day10-st.selectbox)

[![](https://knowledge.insight-lab.co.jp/hubfs/30days_logo.png)](https://knowledge.insight-lab.co.jp/aidx/30daysofstreamlit-day10-st.selectbox)

###### [#30DaysOfStreamlit Day10 st.selectbox](https://knowledge.insight-lab.co.jp/aidx/30daysofstreamlit-day10-st.selectbox)

###### [次の投稿](https://knowledge.insight-lab.co.jp/aidx/30daysofstreamlit-day12-st.checkbox)

[![](https://knowledge.insight-lab.co.jp/hubfs/30days_logo.png)](https://knowledge.insight-lab.co.jp/aidx/30daysofstreamlit-day12-st.checkbox)

###### [#30DaysOfStreamlit Day12 st.checkbox](https://knowledge.insight-lab.co.jp/aidx/30daysofstreamlit-day12-st.checkbox)

##### INFORMATION

INFORMATION

- [会社概要](https://www.insight-lab.co.jp/about/company.html)
- [お問い合わせ](https://www.insight-lab.co.jp/contact.html)

##### MENU

MENU

- [AIDXナレッジ](https://knowledge.insight-lab.co.jp/aidx)
- [NEWS AI SEARCH](https://solution.insight-lab.co.jp/ai/news-ai-search)

[![INSIGHT LAB](https://knowledge.insight-lab.co.jp/hs-fs/hubfs/INSIGHT%20LAB_%E6%96%87%E5%AD%97%E3%81%AE%E3%81%BF_WHT-1.png?width=200&height=55&name=INSIGHT%20LAB_%E6%96%87%E5%AD%97%E3%81%AE%E3%81%BF_WHT-1.png "INSIGHT LAB")](https://www.insight-lab.co.jp/)

- [プライバシーポリシー](https://www.insight-lab.co.jp/privacy.html)

Copyright © 2020 INSIGHT LAB, Inc.

<https://www.facebook.com/AI-Knowledge-204095220273271>