It appears that when you place a UI element above the sidebar layout context manager it causes the app to error.
import matplotlib.pyplot as plt
import numpy as np
from shiny import ui, render
from shiny.express import input, layout
np.random.seed(0)
data = np.random.randn(10000)
ui.h1("test") # causes the app to fail
with layout.sidebar():
ui.input_slider("num_bins", "Number of Bins", min=1, max=50, value=30)
@render.plot
def plot():
plt.hist(data, bins=input.num_bins())
raise ValueError(
ValueError: `layout_sidebar()` is not being supplied with a `sidebar()` object. Please supply a `sidebar()` object to `layout_sidebar(sidebar)`.