Skip to main content

A banner component for displaying important information, alerts, notifications, and types of messages within a Gradio Blocks.

Project description

gradio_banner

PyPI Demo Static Badge

A banner component for displaying important information, alerts, notifications, and types of messages within a Gradio Blocks.

Installation

pip install gradio_banner

Usage

import gradio as gr
from gradio_banner import Banner

with gr.Blocks() as demo:
    with gr.Row():
        Banner(value="Large info banner *with* **markdown** `value`", variant="info")
    with gr.Row():
        Banner(variant="success", size="sm")
    with gr.Row():
        Banner(value="Large warning banner with default label and specified value", variant="warning")
    with gr.Row():
        Banner(variant="error", show_close_button=True)
    with gr.Row():
        with gr.Column():
            with gr.Row():
                Banner(value="Small info banner with close button and without label", size="sm", show_close_button=True, show_label=False)
            with gr.Row():
                Banner(label="Custom label and icon", value="Large info banner with custom icon", icon="https://i.pinimg.com/originals/e9/ab/30/e9ab30fdcadf40bdc095a1e317f3851c.gif")
        with gr.Column():
            Banner(value="Large success banner with specified value", variant="success")

if __name__ == "__main__":
    demo.launch()

Initialization

name type default description
value
str | Callable | None
None
variant
str
"info"
label
str | None
None
icon
str | None
None
size
Literal["sm", "lg"] | None
"lg"
show_close_button
bool
False
show_icon
bool
True
every
Timer | float | None
None
inputs
Component | list[Component] | set[Component] | None
None
show_label
bool | None
None
scale
int | None
None
min_width
int
160
visible
bool
True
rtl
bool
False
elem_id
str | None
None
elem_classes
list[str] | str | None
None
render
bool
True
key
int | str | None
None

Events

name description
change Triggered when the value of the Banner changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See .input() for a listener that is only triggered by user input.
input This listener is triggered when the user changes the value of the Banner.
submit This listener is triggered when the user presses the Enter key while the Banner is focused.

User function

The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).

  • When used as an Input, the component only impacts the input signature of the user function.
  • When used as an output, the component only impacts the return signature of the user function.

The code snippet below is accurate in cases where the component is used as both an input and an output.

  • As output: Is passed, passes text value as a {str} into the function.
  • As input: Should return, expects a {str} returned from function and sets textarea value to it.
def predict(
    value: str | None
) -> str | None:
    return value

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

gradio_banner-1.0.1-py3-none-any.whl (82.0 kB view details)

Uploaded Python 3

File details

Details for the file gradio_banner-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for gradio_banner-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 93d4939648557bc19f06c93fca96f4fce1edb735af8adb9f136c588b5cfec772
MD5 114052c350171a33ac6d61f88c60a09c
BLAKE2b-256 b3ad7f7e348c0cfe49e45f8841eca17b43ebec43bcd7ea07d13281e1daf5ce70

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page