Custom Components GalleryNEW

Explore

New to Gradio? Start here: Getting Started

See the Release History

To install Gradio from main, run the following command:

pip install https://gradio-builds.s3.amazonaws.com/3ab30eefe0cfd2e9c4a23989381e5c583a92c69d/gradio-4.29.0-py3-none-any.whl

*Note: Setting share=True in launch() will not work.

Themes

Description

Customize the look of your app by writing your own custom theme

Base

gradio.Base(···)

Initialization

Parameter Description
primary_hue

colors.Color | str

default: Color()

The primary hue of the theme. Load a preset, like gradio.themes.colors.green (or just the string "green"), or pass your own gradio.themes.utils.Color object.

secondary_hue

colors.Color | str

default: Color()

The secondary hue of the theme. Load a preset, like gradio.themes.colors.green (or just the string "green"), or pass your own gradio.themes.utils.Color object.

neutral_hue

colors.Color | str

default: Color()

The neutral hue of the theme, used . Load a preset, like gradio.themes.colors.green (or just the string "green"), or pass your own gradio.themes.utils.Color object.

text_size

sizes.Size | str

default: Size()

The size of the text. Load a preset, like gradio.themes.sizes.text_sm (or just the string "sm"), or pass your own gradio.themes.utils.Size object.

spacing_size

sizes.Size | str

default: Size()

The size of the spacing. Load a preset, like gradio.themes.sizes.spacing_sm (or just the string "sm"), or pass your own gradio.themes.utils.Size object.

radius_size

sizes.Size | str

default: Size()

The radius size of corners. Load a preset, like gradio.themes.sizes.radius_sm (or just the string "sm"), or pass your own gradio.themes.utils.Size object.

font

fonts.Font | str | Iterable[fonts.Font | str]

default: (<gradio.themes.utils.fonts.GoogleFont (name='Source Sans Pro', weights=(400, 600))>, 'ui-sans-serif', 'system-ui', 'sans-serif')

The primary font to use for the theme. Pass a string for a system font, or a gradio.themes.font.GoogleFont object to load a font from Google Fonts. Pass a list of fonts for fallbacks.

font_mono

fonts.Font | str | Iterable[fonts.Font | str]

default: (<gradio.themes.utils.fonts.GoogleFont (name='IBM Plex Mono', weights=(400, 600))>, 'ui-monospace', 'Consolas', 'monospace')

The monospace font to use for the theme, applies to code. Pass a string for a system font, or a gradio.themes.font.GoogleFont object to load a font from Google Fonts. Pass a list of fonts for fallbacks.

Methods

Methods

push_to_hub

gradio.Base.push_to_hub(repo_name, ···)

Description

Upload a theme to the HuggingFace hub. <br> This requires a HuggingFace account. <br>

Agruments

Parameter Description
repo_name

str

required

The name of the repository to store the theme assets, e.g. 'my_theme' or 'sunset'.

org_name

str | None

default: None

The name of the org to save the space in. If None (the default), the username corresponding to the logged in user, or hƒ_token is used.

version

str | None

default: None

A semantic version tag for theme. Bumping the version tag lets you publish updates to a theme without changing the look of applications that already loaded your theme.

hf_token

str | None

default: None

API token for your HuggingFace account

theme_name

str | None

default: None

Name for the name. If None, defaults to repo_name

description

str | None

default: None

A long form description to your theme.

private

bool

default: False

from_hub

gradio.Base.from_hub(repo_name, ···)

Description

Load a theme from the hub. <br> This DOES NOT require a HuggingFace account for downloading publicly available themes. <br>

Agruments

Parameter Description
repo_name

str

required

string of the form <author>/<theme-name>@<semantic-version-expression>. If a semantic version expression is omitted, the latest version will be fetched.

hf_token

str | None

default: None

HuggingFace Token. Only needed to download private themes.

load

gradio.Base.load(path, ···)

Description

Load a theme from a json file. <br>

Agruments

Parameter Description
path

str

required

The filepath to read.

dump

gradio.Base.dump(filename, ···)

Description

Write the theme to a json file. <br>

Agruments

Parameter Description
filename

str

required

The path to write the theme too

from_dict

gradio.Base.from_dict(theme, ···)

Description

Create a theme instance from a dictionary representation. <br>

Agruments

Parameter Description
theme

dict[str, dict[str, str]]

required

The dictionary representation of the theme.

to_dict

gradio.Base.to_dict(···)

Description

Convert the theme into a python dictionary.