Skip to main content

An all-in-one place, to find complex or just natively unavailable components on streamlit.

Project description

Extra-Streamlit-Components

Downloads

An all-in-one place, to find complex or just not available components by default on streamlit.

Components

Firstly, add import extra_streamlit_components as stx

  • Router

  • Route to specific pages in Streamlit. This leverages the use of query parameters to make custom routes in your Streamlit application. For best experience, make sure to include the st.cache function decorator while initializing the Router object.

      @st.cache(allow_output_mutation=True, hash_funcs={"_thread.RLock": lambda _: None})
      def init_router():
          return stx.Router({"/home": home, "/landing": landing})
    
      def home():
          return st.write("This is a home page")
    
      def landing():
          return st.write("This is the landing page")
    
      router = init_router()
      router.show_route_view()
    
      c1, c2, c3 = st.columns(3)
    
      with c1:
          st.header("Current route")
          current_route = router.get_url_route()
          st.write(f"{current_route}")
      with c2:
          st.header("Set route")
          new_route = st.text_input("route")
          if st.button("Route now!"):
              router.route(new_route)
      with c3:
          st.header("Session state")
          st.write(st.session_state)
    
  • Cookie Manager

    The long awaited between-sessions in-browser cookies store and manager! It stores cookies in a strict same-site behaviour.

    To add an expiry date to a cookie use the expires_at parameter in the set function. By default, it will expire after 1 day.

    Security Note: In shared domains such as share.streamlit.io, other web developers can have access to the cookies you set and the same goes for you. This is not to be treaded as security bug but a circumstance the developer need to be aware of.

    import datetime
    st.write("# Cookie Manager")
    
    @st.cache(allow_output_mutation=True)
    def get_manager():
        return stx.CookieManager()
    
    cookie_manager = get_manager()
    
    st.subheader("All Cookies:")
    cookies = cookie_manager.get_all()
    st.write(cookies)
    
    c1, c2, c3 = st.columns(3)
    
    with c1:
        st.subheader("Get Cookie:")
        cookie = st.text_input("Cookie", key="0")
        clicked = st.button("Get")
        if clicked:
            value = cookie_manager.get(cookie=cookie)
            st.write(value)
    with c2:
        st.subheader("Set Cookie:")
        cookie = st.text_input("Cookie", key="1")
        val = st.text_input("Value")
        if st.button("Add"):
            cookie_manager.set(cookie, val, expires_at=datetime.datetime(year=2022, month=2, day=2))
    with c3:
        st.subheader("Delete Cookie:")
        cookie = st.text_input("Cookie", key="2")
        if st.button("Delete"):
            cookie_manager.delete(cookie)
    

  • TabBar

    Inspire from React's ScrollMenu, this component receives a list of TabBarItemData, and returns the id of the selected tab

    chosen_id = stx.tab_bar(data=[
        stx.TabBarItemData(id=1, title="ToDo", description="Tasks to take care of"),
        stx.TabBarItemData(id=2, title="Done", description="Tasks taken care of"),
        stx.TabBarItemData(id=3, title="Overdue", description="Tasks missed out"),
    ], default=1)
    st.info(f"{chosen_id=}")
    

  • BouncingImage

    Probably not the best naming but this component, renders an image by its path or url, and animates by zooming in and out repetitively giving an illusion of a bounce.

    image_url = "https://streamlit.io/images/brand/streamlit-logo-secondary-colormark-darktext.svg"
    stx.bouncing_image(image_source=image_url, animate=True, animation_time=1500, height=200, width=600)
    

  • StepperBar

    A streamlit wrapper on MaterialUI's Stepper

    val = stx.stepper_bar(steps=["Ready", "Get Set", "Go"])
    st.info(f"Phase #{val}")
    

"Buy Me A Coffee"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

extra_streamlit_components-0.1.55.tar.gz (2.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

extra_streamlit_components-0.1.55-py3-none-any.whl (2.2 MB view details)

Uploaded Python 3

File details

Details for the file extra_streamlit_components-0.1.55.tar.gz.

File metadata

  • Download URL: extra_streamlit_components-0.1.55.tar.gz
  • Upload date:
  • Size: 2.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.10

File hashes

Hashes for extra_streamlit_components-0.1.55.tar.gz
Algorithm Hash digest
SHA256 44dd626214c3665962109a7b9fa83e79d6bcf91de209d8ea00acd428a107ddd2
MD5 c66dd2e8a393630bf3ffe872bcfe6c90
BLAKE2b-256 3dc27f190af8db295f0c0f40e3dc7ef2b6491e643a1456ab2d87165680408d26

See more details on using hashes here.

File details

Details for the file extra_streamlit_components-0.1.55-py3-none-any.whl.

File metadata

  • Download URL: extra_streamlit_components-0.1.55-py3-none-any.whl
  • Upload date:
  • Size: 2.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.10

File hashes

Hashes for extra_streamlit_components-0.1.55-py3-none-any.whl
Algorithm Hash digest
SHA256 77bf07739cc7eacda4b681555cb2d3d78d5686415daccb2694162b0300f0e829
MD5 46840009f63f5d2e01602f02dc957d07
BLAKE2b-256 a3baf269b6ccbd0565a4ec4f58d8d57dd5e893677bc1594051e0506493d358c0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page