Jupyter Vue Widgets Base

1.12.0 · active · verified Tue Apr 21

jupyter-vue is the JavaScript/TypeScript frontend component of the ipyvue Python library, providing a foundation for building interactive Jupyter widgets using Vue.js. It enables developers to integrate reactive Vue components directly into Jupyter notebooks and JupyterLab environments. The library is actively maintained, currently at version 1.12.0, with regular minor releases addressing bug fixes and introducing new features. Its key differentiator is simplifying the creation of complex, interactive frontend components within Jupyter by leveraging the Vue.js framework for reactivity and templating, abstracting away much of the boilerplate typically associated with traditional Jupyter widget development. This allows for more dynamic and rich user interfaces.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates creating and displaying a reactive Vue component widget using the `ipyvue` Python library, which relies on `jupyter-vue` for frontend rendering. This example includes a counter with increment/decrement buttons and a text input field, showcasing two-way data binding and method calling between Python and Vue.

from ipyvue import VueTemplate
from IPython.display import display

class InteractiveCounter(VueTemplate):
    template = """
    <template>
        <div style="border: 1px solid #ccc; padding: 10px; border-radius: 5px; background-color: #f9f9f9;">
            <h3 style="color: #333;">Vue Counter Widget</h3>
            <p>Current Count: <strong style="color: #007bff;">{{ count }}</strong></p>
            <button @click="increment" style="margin-right: 5px; padding: 8px 15px; border: none; border-radius: 4px; background-color: #28a745; color: white; cursor: pointer;">Increment</button>
            <button @click="decrement" style="padding: 8px 15px; border: none; border-radius: 4px; background-color: #dc3545; color: white; cursor: pointer;">Decrement</button>
            <p style="margin-top: 15px;">User Input: <em style="color: #6c757d;">{{ inputText }}</em></p>
            <input v-model="inputText" placeholder="Type something here..." style="width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px; box-sizing: border-box;">
        </div>
    </template>
    """
    data = {
        'count': 0,
        'inputText': 'Hello ipyvue!'
    }

    def increment(self):
        self.count += 1

    def decrement(self):
        self.count -= 1

widget = InteractiveCounter()
display(widget)
# In a Jupyter Notebook/Lab cell, 'widget' on the last line
# would implicitly display it without an explicit 'display()' call.

view raw JSON →