Skip to main content
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.

Rows

Use gr.Row() to arrange components horizontally:
Both buttons will appear side by side on the same horizontal line.

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

The scale parameter determines how components expand to fill available space:
  • scale=0: Component does not expand, takes only the space it needs
  • scale=1 or higher: Component expands proportionally to its scale value
In this example, btn2 will be twice as wide as btn1, while btn0 stays at its minimum size.

The min_width parameter

The min_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 a gr.Column() are stacked vertically. Since vertical stacking is the default, columns are most useful when nested inside rows:
In this layout:
  • 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 the scale parameter:
The second column will be twice as wide as the first.
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), use fill_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 explicit height 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 with gr.Tab(). Each tab selectively shows or hides its contents:
Consecutive 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:
The open parameter controls whether the accordion starts expanded or collapsed.
Learn more in the Accordion documentation.
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 the Walkthrough component with Step components:
The 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 a visible parameter that can be set initially and updated dynamically:
Setting 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 using gr.Examples, you need to pass the input component to it, but might want to render the examples first:
The .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:
The textbox will appear in the third column.

Next steps

Now that you know how to control layout, you can: