29  App Colours

There are a few parts of Streamlit’s theming that we can officially change using a configuration file.

This file needs to be called config.toml and lives inside a subfolder called .streamlit

The config.toml file contains a variable number of parameters.

It can determine whether the default colourscheme is light or dark, and whether the default streamlit colours are overridden.

You can create a template config.toml from within streamlit, then paste the output into a config.toml file you create yourself.

Let’s look at an example app.

29.0.1 config.toml

[theme]
base="light"
primaryColor="#005EB8"
secondaryBackgroundColor="#00e0ff"

29.0.2 app.py

import streamlit as st

st.title('Simple Calculator App')

num_1 = st.number_input(label="First Number")

num_2 = st.number_input(label="Second Number")

operator = st.selectbox(label="Operation", options=["Add", "Subtract", "Multiply", "Divide"])

if operator == "Add":
    output = num_1 + num_2
elif operator == "Subtract":
    output = num_1 - num_2
elif operator == "Multiply":
    output = num_1 * num_2
elif operator == "Divide":
    output = num_1 / num_2

st.text(f"The answer is {output}")