By default, components in Blocks are arranged vertically. But you have full control over how components are positioned using layout elements. Under the hood, Gradio uses the flexbox model from web development.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/gradio-app/gradio/llms.txt
Use this file to discover all available pages before exploring further.
Rows
Usegr.Row() to arrange components horizontally:
Equal height
You can make all elements in a row have the same height:Controlling width with scale and min_width
Every component has two parameters that control its width within a row:The scale parameter
Thescale parameter determines how components expand to fill available space:
scale=0: Component does not expand, takes only the space it needsscale=1or higher: Component expands proportionally to its scale value
btn2 will be twice as wide as btn1, while btn0 stays at its minimum size.
The min_width parameter
Themin_width parameter sets the minimum width (in pixels) that a component will take. If there isn’t enough space to satisfy all min_width values, the row will wrap:
Learn more about Rows in the Row documentation.
Columns and nesting
Components within agr.Column() are stacked vertically. Since vertical stacking is the default, columns are most useful when nested inside rows:
- The first column contains two textboxes stacked vertically
- The second column contains an image and a button stacked vertically
- Both columns sit side by side in the row
Controlling column width
Just like components in rows, columns support thescale parameter:
Learn more about Columns in the Column documentation.
Fill browser height and width
Full width
To make your app take the full width of the browser (removing side padding), usefill_width=True:
Full height
To make top-level components expand to fill the browser height:Components need
scale >= 1 to expand vertically when fill_height=True is enabled.Dimensions
Some components support explicitheight and width parameters. These accept either:
- A number: Interpreted as pixels
- A string: Allows any CSS unit (px, em, rem, vh, vw, etc.)
Tabs
Create tabbed interfaces withgr.Tab(). Each tab selectively shows or hides its contents:
gr.Tab() contexts are automatically grouped together. Only one tab can be selected at a time, and only that tab’s components are visible.
Learn more in the Tab documentation.
Accordions
Accordions provide collapsible sections that can be toggled open or closed:open parameter controls whether the accordion starts expanded or collapsed.
Learn more in the Accordion documentation.
Sidebar
The sidebar creates a collapsible panel on the left side of the screen:Learn more in the Sidebar documentation.
Multi-step walkthroughs
For guided workflows, use theWalkthrough component with Step components:
Walkthrough component has a visual style tailored for step-by-step workflows. You control progression by setting the appropriate step ID.
Learn more in the Walkthrough documentation.
Visibility
Both components and layout elements have avisible parameter that can be set initially and updated dynamically:
gr.Column(visible=False) on a column hides all components inside it.
Defining and rendering components separately
Sometimes you need to define a component before you render it in the UI. For example, when usinggr.Examples, you need to pass the input component to it, but might want to render the examples first:
.render() method places the component wherever you call it.
Unrendering and moving components
You can also move a component by unrendering it and rendering it elsewhere:Next steps
Now that you know how to control layout, you can:- Learn about managing state in your applications
- Build dynamic apps with the render decorator
- Add custom CSS for advanced styling