Spaces:
Running
Running
A newer version of the Gradio SDK is available:
5.35.0
Lifecycle
A Lifecycle component for getting the current user's environment information.
- Get the current user's language, page theme, user agent, and screen state.
- Listen to page actions and trigger corresponding events (page loading, size changes, page closing, etc.).
How to Use
Basic Usage
Automatically Adapt to User Language Environment
Return Different Weighted Content Based on UI Theme
API and Parameter List
Value
Interface definition:
class LifecycleScreenData(GradioModel):
width: float
height: float
scrollX: float
scrollY: float
class LifecycleData(GradioModel):
screen: LifecycleScreenData
language: str
theme: str
userAgent: str
Props
This component does not support passing in props.
Event Listeners
Event | Description |
---|---|
mgr.Lifecycle.mount(fn, 路路路) |
Triggered when the user's page loads. The EventData is a dictionary type value of the current component's value. |
mgr.Lifecycle.unmount(fn, 路路路) |
Triggered when the user's page closes. The EventData is a dictionary type value of the current component's value. |
mgr.Lifecycle.resize(fn, 路路路) |
Triggered when custom labels trigger events. The EventData is a dictionary type value of the current component's value. |