Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Container

A vertical box for grouping components. Column is an alias of Container.

with sc.Container(border=True, border_title='Settings', height=320):
    sc.Checkbox('Enable caching')
    sc.NumberInput('Workers', value=4)
ArgumentTypeMeaning
widthsize keywordWidth
weightfloatFlex-grow ratio inside a Row
borderboolDraw a frame
border_titlestr | PropertyTitle drawn in the top border
heightsize keywordFixed height; content scrolls
animatedboolAnimate the height when visible flips
visiblebool | PropertyDefault True

Properties: border_title, visible.

Scrolling

A fixed height caps the box and makes it scroll:

with sc.Container(height=240):
    for line in lines:
        sc.Text(line)

max_height has the same effect. min_height does not.

Stretching inside a row

height='stretch' makes the container fill the parent’s height. Inside a Row, it spans the row’s tallest sibling:

with sc.Row():
    with sc.Container(height='stretch'):
        sc.Text('Left')
    with sc.Container(height='stretch'):
        sc.Text('Right')

Showing and hiding

visible controls whether the container is rendered. animated=True transitions the height instead of making it pop:

with sc.Container(visible=state.show_advanced, animated=True):
    sc.Text('Advanced options')

The container stays in the tree either way, so a later patch can bring it back.

Border title

border_title is only honored with border=True. It is drawn inline in the frame, the way a <legend> sits in a fieldset.