docstr: Insert a multi-element container that can be expanded/collapsed.
  
  Inserts a container into your app that can be used to hold multiple elements
  and can be expanded or collapsed by the user. When collapsed, all that is
  visible is the provided label.
  
  To add elements to the returned container, you can use "with" notation
  (preferred) or just call methods directly on the returned object. See
  examples below.
  
  .. warning::
      Currently, you may not put expanders inside another expander.
  
  Parameters
  ----------
  label : str
      A string to use as the header for the expander. The label can optionally
      contain Markdown and supports the following elements: Bold, Italics,
      Strikethroughs, Inline Code, Emojis, and Links.
  
      This also supports:
  
      * Emoji shortcodes, such as ``:+1:``  and ``:sunglasses:``.
        For a list of all supported codes,
        see https://share.streamlit.io/streamlit/emoji-shortcodes.
  
      * LaTeX expressions, by wrapping them in "$" or "$$" (the "$$"
        must be on their own lines). Supported LaTeX functions are listed
        at https://katex.org/docs/supported.html.
  
      * Colored text, using the syntax ``:color[text to be colored]``,
        where ``color`` needs to be replaced with any of the following
        supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
  
      Unsupported elements are unwrapped so only their children (text contents) render.
      Display unsupported elements as literal characters by
      backslash-escaping them. E.g. ``1\. Not an ordered list``.
  expanded : bool
      If True, initializes the expander in "expanded" state. Defaults to
      False (collapsed).
  
  Examples
  --------
  You can use `with` notation to insert any element into an expander
  
  >>> import streamlit as st
  >>>
  >>> st.bar_chart({"data": [1, 5, 2, 6, 2, 1]})
  >>>
  >>> with st.expander("See explanation"):
  ...     st.write(\"\"\"
  ...         The chart above shows some numbers I picked for you.
  ...         I rolled actual dice for these, so they're *guaranteed* to
  ...         be random.
  ...     \"\"\")
  ...     st.image("https://static.streamlit.io/examples/dice.jpg")
  
  .. output ::
      https://doc-expander.streamlit.app/
      height: 750px
  
  Or you can just call methods directly in the returned objects:
  
  >>> import streamlit as st
  >>>
  >>> st.bar_chart({"data": [1, 5, 2, 6, 2, 1]})
  >>>
  >>> expander = st.expander("See explanation")
  >>> expander.write(\"\"\"
  ...     The chart above shows some numbers I picked for you.
  ...     I rolled actual dice for these, so they're *guaranteed* to
  ...     be random.
  ... \"\"\")
  >>> expander.image("https://static.streamlit.io/examples/dice.jpg")
  
  .. output ::
      https://doc-expander.streamlit.app/
      height: 750px
code: def expander(
      self, label: str, expanded: bool = False
  ) -> "DeltaGenerator":
      r"""Insert a multi-element container that can be expanded/collapsed.
  
      Inserts a container into your app that can be used to hold multiple elements
      and can be expanded or collapsed by the user. When collapsed, all that is
      visible is the provided label.
  
      To add elements to the returned container, you can use "with" notation
      (preferred) or just call methods directly on the returned object. See
      examples below.
  
      .. warning::
          Currently, you may not put expanders inside another expander.
  
      Parameters
      ----------
      label : str
          A string to use as the header for the expander. The label can optionally
          contain Markdown and supports the following elements: Bold, Italics,
          Strikethroughs, Inline Code, Emojis, and Links.
  
          This also supports:
  
          * Emoji shortcodes, such as ``:+1:``  and ``:sunglasses:``.
            For a list of all supported codes,
            see https://share.streamlit.io/streamlit/emoji-shortcodes.
  
          * LaTeX expressions, by wrapping them in "$" or "$$" (the "$$"
            must be on their own lines). Supported LaTeX functions are listed
            at https://katex.org/docs/supported.html.
  
          * Colored text, using the syntax ``:color[text to be colored]``,
            where ``color`` needs to be replaced with any of the following
            supported colors: blue, green, orange, red, violet, gray/grey, rainbow.
  
          Unsupported elements are unwrapped so only their children (text contents) render.
          Display unsupported elements as literal characters by
          backslash-escaping them. E.g. ``1\. Not an ordered list``.
      expanded : bool
          If True, initializes the expander in "expanded" state. Defaults to
          False (collapsed).
  
      Examples
      --------
      You can use `with` notation to insert any element into an expander
  
      >>> import streamlit as st
      >>>
      >>> st.bar_chart({"data": [1, 5, 2, 6, 2, 1]})
      >>>
      >>> with st.expander("See explanation"):
      ...     st.write(\"\"\"
      ...         The chart above shows some numbers I picked for you.
      ...         I rolled actual dice for these, so they're *guaranteed* to
      ...         be random.
      ...     \"\"\")
      ...     st.image("https://static.streamlit.io/examples/dice.jpg")
  
      .. output ::
          https://doc-expander.streamlit.app/
          height: 750px
  
      Or you can just call methods directly in the returned objects:
  
      >>> import streamlit as st
      >>>
      >>> st.bar_chart({"data": [1, 5, 2, 6, 2, 1]})
      >>>
      >>> expander = st.expander("See explanation")
      >>> expander.write(\"\"\"
      ...     The chart above shows some numbers I picked for you.
      ...     I rolled actual dice for these, so they're *guaranteed* to
      ...     be random.
      ... \"\"\")
      >>> expander.image("https://static.streamlit.io/examples/dice.jpg")
  
      .. output ::
          https://doc-expander.streamlit.app/
          height: 750px
  
      """
      if label is None:
          raise StreamlitAPIException(
              "A label is required for an expander"
          )
  
      expandable_proto = BlockProto.Expandable()
      expandable_proto.expanded = expanded
      expandable_proto.label = label
  
      block_proto = BlockProto()
      block_proto.allow_empty = False
      block_proto.expandable.CopyFrom(expandable_proto)
  
      return self.dg._block(block_proto=block_proto)
  
file_path: streamlit/lib/streamlit/elements/layouts.py
imports: from __future__ import annotations
  from typing import TYPE_CHECKING, List, Literal, Optional, Sequence, Union, cast
  from streamlit.errors import StreamlitAPIException
  from streamlit.proto.Block_pb2 import Block
  from streamlit.runtime.metrics_util import gather_metrics
label_desc: Use image node_id 4 for calling the LayoutsMixin obj's underlying member method code with example usage: obj.expander(label, expanded) and returns: self