from typing import Literal import streamlit as st MARGINS = { "top": "0", "bottom": "0", } STICKY_CONTAINER_HTML = """
""".strip() # Not to apply the same style to multiple containers count = 0 def sticky_container( *, height: int | None = None, border: bool | None = None, mode: Literal["top", "bottom"] = "top", margin: str | None = None, z:int |None=None ): if margin is None: margin = MARGINS[mode] global count html_code = STICKY_CONTAINER_HTML.format(position=mode, margin=margin, i=count,z=z) count += 1 container = st.container(height=height, border=border) container.markdown(html_code, unsafe_allow_html=True) return container