Multipaging: A short guide

There are ways to have a multipage content

Native multipaging

  • Problem: You don’t want streamlit_book multipaging, but streamlit’s native multipaging.

  • Solution: Just pust your files on pages/ and import streamlit_book on the files where you need them. You can mix streamlit_book and streamlit’s native multipaging.

Single page

  • Problem: You have one page to show, but you want to use the activities/questions provided on streamlit_book.

  • Solution: Just import the library streamlit_book without the setup and call the required functions.

import streamlit as st
import streamlit_book as stb


# No need to initialize the streamlit_book library
stb.true_or_false("Are you a robot?", False)

Chapter: A single document with multiple connected pages

  • Problem: You want cute multipages, but you only need previous/next buttons.

  • Solution: Use method set_chapter_config` to set the path and other chapter configurations.

import streamlit as st
import streamlit_book as stb

# Set wide display

# Set multipage
stb.set_chapter_config(path="pages/", save_answers=True)

Using the function set_chapter_config:

  • Will setup the page navigation text/icons for a unique chapter.

  • Will sort the python and markdown files of the given path on lexigraphic order.

  • Will read and render the files into streamlit, allowing a enriched markdown/python of the implemented activities.

See the function set_chapter_config required and optional parameters on the Multipaging Documentation.

Book: Having several chapters

Requires a sidebar menu (like this demo), where each topic required a previous/next buttons.

Use stb.set_book_config` to set the path and the configuration for the book.

import streamlit as st
import streamlit_book as stb

# Streamlit webpage properties

# Streamit book properties
                            "What's new on v0.7.0?",
                            "Core Features",
                          "pages/", # single file
                          "pages/01 Multitest", # a folder

Using the function set_book_config:

  • Will setup a sidebar menu with each of the chapter.

  • Each chapter is build with pagination for the provided file/folder.

The capability to render several chapters was added in version 0.7.0, and makes a direct use of an awesome library to add a sidebar menu called (streamlit_option_menu). Kudos to the creator. It delivers a professional look, and allows to add icons by name makes it a lot more user-friendly.

See the function set_book_config required and optional parameters on the Multipaging Documentation.