π°Β Β Row Layout
Submitted by Lukas Masuch
Summary
A multi-element horizontal container that places elements in a row.
Functions
row
Insert a multi-element, horizontal container into your app.
This function inserts a container into your app that can hold a number of elements as defined in the provided spec. Elements can be added to the returned container by calling methods directly on the returned object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spec |
SpecType
|
Controls the number and width of cells to insert in the row. Can be one of:
* An integer specifying the number of cells. All cells will have equal
width in this case.
* An iterable of numbers (int or float) that specifies the relative width of
each cell. For instance, |
required |
gap |
Optional[str]
|
"small", "medium", or "large" The size of the gap between cells, can be "small", "medium", or "large". This parameter specifies the visual space between the elements within the row. Defaults to "small". |
'small'
|
vertical_align |
Literal['top', 'center', 'bottom']
|
The vertical alignment of the cells in the row. It can be either "top", "center", or "bottom", aligning the contents of each cell accordingly. Defaults to "top". |
'top'
|
Returns:
Type | Description |
---|---|
GridDeltaGenerator
|
grid.GridDeltaGenerator: RowContainer A row container object. Elements can be added to this row by calling methods directly on the returned object. |
Source code in src/streamlit_extras/row/__init__.py
Import:
- You should add this to the top of your .py file
Examples
example
def example():
random_df = pd.DataFrame(np.random.randn(20, 3), columns=["a", "b", "c"])
row1 = row(2, vertical_align="center")
row1.dataframe(random_df, use_container_width=True)
row1.line_chart(random_df, use_container_width=True)
row2 = row([2, 4, 1], vertical_align="bottom")
row2.selectbox("Select Country", ["Germany", "Italy", "Japan", "USA"])
row2.text_input("Your name")
row2.button("Send", use_container_width=True)