🟰 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:
|
required |
gap
|
Optional[str]
|
The size of the gap between cells, can be "small", "medium", or "large". Defaults to "small". |
'small'
|
vertical_align
|
Literal['top', 'center', 'bottom']
|
The vertical alignment of the cells in the row. Defaults to "top". |
'top'
|
Returns:
| Type | Description |
|---|---|
GridDeltaGenerator
|
grid.GridDeltaGenerator: A row container object. Elements can be added to this row by calling methods directly on the returned object. |
Deprecated
This function is deprecated. Use
st.container(horizontal=True)
instead.
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() -> None:
random_df = pd.DataFrame(np.random.randn(20, 3), columns=["a", "b", "c"])
row1 = row(2, vertical_align="center")
row1.dataframe(random_df, width="stretch")
row1.line_chart(random_df, width="stretch")
row2 = row([2, 4, 1], vertical_align="bottom")
row2.selectbox("Select Country", ["Germany", "Italy", "Japan", "USA"])
row2.text_input("Your name")
row2.button("Send", width="stretch")