Skip to main content

tags: [gradio-custom-component, SideBar] title: gradio_topbar short_description: A TopBar for Gradio Interface colorFrom: blue colorTo: yellow sdk: gradio pinned: false app_file: space.py

gradio_topbar

PyPI - Version

A TopBar for Gradio Interface

Installation

pip install gradio_topbar

Usage

# demo/app.py

import gradio as gr
import time
from gradio_topbar import TopBar

def chat_response(message, history):
    history = history or ""
    history += f"You: {message}\n"
    time.sleep(1) # Simulate thinking
    history += f"Bot: Thanks for the message! You said: '{message}'\n"
    return history, ""

def update_label(value):
    return f"Current temperature is: {value}"

with gr.Blocks(theme=gr.themes.Ocean(), title="Full Layout Demo") as demo:
    gr.Markdown(
        """
        # TopBar Demo
        This demo shows the `TopBar` with `width="50%"` and `bring_to_front=True`.
        Notice how the bar is now horizontally centered and no longer full-width.
        """
    )

    with TopBar(open=True, height=180, width="50%", bring_to_front=True, rounded_borders=True):
        with gr.Row():
            message_box = gr.Textbox(
                show_label=False,
                placeholder="Type your message here...",
                elem_id="message-input",
                scale=7
            )
            send_button = gr.Button("Send", variant="primary", scale=1)
        with gr.Row():
            gr.Button("Upload File")
            gr.Button("Record Audio")
            gr.ClearButton([message_box])

    with gr.Row(equal_height=True):
        with gr.Column(scale=3):
            gr.Markdown("### 🤖 Chat Interface")
            chatbot_display = gr.Textbox(
                label="Chat History",
                lines=25,
                interactive=False
            )

    send_button.click(
        fn=chat_response,
        inputs=[message_box, chatbot_display],
        outputs=[chatbot_display, message_box]
    )
    message_box.submit(
        fn=chat_response,
        inputs=[message_box, chatbot_display],
        outputs=[chatbot_display, message_box]
    )

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

TopBar

Initialization

name type default description
label
str | gradio.i18n.I18nData | None
None name of the top bar. Not displayed to the user.
open
bool
True if True, top bar is open by default.
visible
bool
True If False, the component will be hidden.
elem_id
str | None
None An optional string that is assigned as the id of this component in the HTML DOM. Can be used for targeting CSS styles.
elem_classes
list[str] | str | None
None An optional string or list of strings that are assigned as the class of this component in the HTML DOM. Can be used for targeting CSS styles.
render
bool
True If False, this layout will not be rendered in the Blocks context. Should be used if the intention is to assign event listeners now but render the component later.
height
int | str
320 The height of the top bar, specified in pixels if a number is passed, or in CSS units if a string is passed.
width
int | str
"100%" The width of the top bar, specified in pixels if a number is passed, or in CSS units (like "80%") if a string is passed. The bar will be horizontally centered.
bring_to_front
bool
False If True, the TopBar will be rendered on top of all other elements with a higher z-index. Defaults to False.
rounded_borders
bool
False If True, applies rounded borders to the bottom edges of the TopBar panel.
key
int | str | tuple[int | str, Ellipsis] | None
None in a gr.render, Components with the same key across re-renders are treated as the same component, not a new component. Properties set in 'preserved_by_key' are not reset across a re-render.
preserved_by_key
list[str] | str | None
None A list of parameters from this component's constructor. Inside a gr.render() function, if a component is re-rendered with the same key, these (and only these) parameters will be preserved in the UI (if they have been changed by the user or an event listener) instead of re-rendered based on the values provided during constructor.

Events

name description
expand This listener is triggered when the TopBar is expanded.
collapse This listener is triggered when the TopBar is collapsed.

Metadata

Release files for gradio-topbar 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gradio-topbar 0.0.2
File Size Uploaded Provenance Actions
gradio_topbar-0.0.2.tar.gz 144.8 kB Without provenance Details for gradio_topbar-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gradio-topbar 0.0.2
File Interpreter ABI Platform Actions
gradio_topbar-0.0.2-py3-none-any.whl Python 3 none any Details for gradio_topbar-0.0.2-py3-none-any.whl

Total release size: 227.6 kB

Release files / gradio_topbar-0.0.2.tar.gz

Download URL gradio_topbar-0.0.2.tar.gz
Size 144.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ce44c4b573734efaf883174a3e22785166d7e5e41b53df1ae0d84415222e244f
BLAKE2b-256 checksum
How to use checksums
00988c406ce6e6ee9dbc81cd63ed52bf52bc088cb1703aee5cb6774e665ce2c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.11

Release files / gradio_topbar-0.0.2-py3-none-any.whl

Download URL gradio_topbar-0.0.2-py3-none-any.whl
Size 82.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5dc7846c847387a2a1033f0c1a10819d0f0de8c49f884e833693d6de6a6e83e8
BLAKE2b-256 checksum
How to use checksums
d79ae4df9be34eeb443a03c7c2f5d16278d744e4d9688ad4d08a761310d895a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.11

Security for gradio-topbar 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page