ipyvuetify
ipyvuetify is a Python library that provides Jupyter widgets based on Vuetify UI components, implementing Google's Material Design specification with the Vue.js framework. It allows users to build modern, interactive graphical user interfaces directly within Jupyter notebooks (classic and Lab) and dashboards (Voila). The library is currently at version 1.11.3, with an experimental alpha branch for 3.x, and aims to offer a richer set of customizable and composable widgets compared to standard ipywidgets.
Warnings
- breaking ipyvuetify's API conventions differ significantly from standard ipywidgets and direct Vuetify HTML. Component names are CamelCase with 'v-' stripped (e.g., `v.Btn` for `<v-btn>`). Attributes are snake_case (e.g., `offset_y` for `offset-y`). Child components and text are passed via the `children` traitlet, and event listeners are set using the `.on_event(event_name, callback)` method. CSS `class` and `style` attributes require an underscore suffix (`class_`, `style_`).
- gotcha In-place mutations of list or dictionary traitlets (e.g., appending to `my_list_traitlet.append('item')`) are not detected by ipywidgets' change notification system, which ipyvuetify relies upon. This means the frontend widget will not update.
- gotcha The `value` attribute on ipyvuetify widgets is primarily for *setting* an initial value and does not reflect user interactions or two-way data binding. For interactive components where the user's input needs to be read, use the `v_model` attribute instead.
- breaking ipyvuetify 3.0.0a2 and subsequent 3.x alpha releases are unstable, based on Vue 3.x, and primarily for future Solara 3.0 integration. They may have significant visual and functional breakage (e.g., issues with Vuetify2 appearance) and are not recommended for general use with ipyvuetify 1.x-based applications.
- gotcha For users of JupyterLab, a separate JupyterLab extension must be installed (`jupyter labextension install jupyter-vuetify`) in addition to the pip package for ipyvuetify widgets to render correctly.
- gotcha In Google Colab environments, `ipyvuetify` widgets may fail to render with an 'Unknown dependency jupyter-vue' error due to how Colab handles widget dependencies. This typically requires specific workarounds involving ensuring the `jupyter-vue` module is explicitly loaded.
- gotcha The `v.FileUpload` widget has been reported to cause kernel crashes (`Kernel died`) when used with `ipykernel` versions greater than 6.29.
Install
-
pip install ipyvuetify -
jupyter labextension install jupyter-vuetify
Imports
- v
import ipyvuetify
import ipyvuetify as v
- Btn
v.v_btn() or v.button()
v.Btn()
Quickstart
import ipyvuetify as v
from IPython.display import display
# Create a text field to display messages
message_output = v.TextField(label="Message", readonly=True, v_model="Click the button!")
# Define a callback function for the button click
def on_button_click(widget, event, data):
message_output.v_model = "Button was clicked!"
# Create a button and attach the event listener
button = v.Btn(children=["Click Me"])
button.on_event('click', on_button_click)
# Display the widgets within a container
display(v.Container(children=[button, message_output]))