Skip to main content

Fix Streamlit containers relative to viewport instead of page

Project description

streamlit-float PyPi - Downloads

Fix the vertical position of Streamlit containers relative to viewport instead of page

Installation

Install streamlit-float with pip:

pip install streamlit-float

Usage

This package provides two ways to float a container. The first is to call the float method of a container:

import streamlit as st
from streamlit_float import *

# initialize float feature/capability
float_init()

col1, col2 = st.columns(2)

# Fix/float the whole column
col1.write("This entire column is fixed/floating")
col1.float()

with col2:
    container = st.container()
    # Fix/float a single container inside
    container.write("This text is in a container that is fixed")
    container.float()

Alternatively, you can use the float_parent method:

import streamlit as st
from streamlit_float import *

# initialize float feature/capability
float_init()

col1, col2 = st.columns(2)

# Fix/float the whole column
with col1:
    st.write("This entire column is fixed/floating")
    float_parent()

with col2:
    container = st.container()
    # Fix/float a single container inside
    with container:
        st.write("This text is in a container that is fixed")
        float_parent()

Note that the float feature does not work well with expander and tabs containers. Also, it is recommended to call the float methods on a container after all the content has been added to it.

If instead you would like to float/fix a container that is constructed in html markup and added using Streamlits markdown method (with unsafe_allow_html=True), make sure to add 'floating' to the containers classlist.

st.markdown('''<div class="floating">..content..</div>''', unsafe_allow_html=True)

License

This project is licensed under the MIT License

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

streamlit-float-0.2.6.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

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

streamlit_float-0.2.6-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file streamlit-float-0.2.6.tar.gz.

File metadata

  • Download URL: streamlit-float-0.2.6.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for streamlit-float-0.2.6.tar.gz
Algorithm Hash digest
SHA256 66fe364790c312c87f564bf33f6de6155612da83e7a3272ac58db0645f9b7cea
MD5 289802d6be93af09c2a12ff26ff6679b
BLAKE2b-256 7d4b935a2436bccbfdbe3bb9edc901bfae8e690b20e48d163f83c356dbbd5cef

See more details on using hashes here.

File details

Details for the file streamlit_float-0.2.6-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_float-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 1354432ab35a199a2d64541a1fc9c35911598cd4827208b0033cd44b29fe64d8
MD5 e08fdce9afffda5c3b3bd08776830524
BLAKE2b-256 cd1c411ee1d23784e9a6ab87e5b30741f04374c39dff09569bd9bc91972b5740

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