{"id":10226,"library":"shinywidgets","title":"Shiny Widgets Integration","description":"shinywidgets facilitates the rendering and interactive use of `ipywidgets` within `Shiny for Python` applications. It bridges the gap between the rich interactive capabilities of `ipywidgets` and the reactive framework of Shiny, allowing users to embed existing widget ecosystems like `ipyleaflet`, `plotly.graph_objects.FigureWidget`, and `ipyvolume` directly into their Shiny apps. The current version is 0.8.0, with a fairly active release cadence, often addressing compatibility with new versions of `ipywidgets`, `plotly`, and `websockets`.","status":"active","version":"0.8.0","language":"python","source_language":"en","source_url":"https://github.com/rstudio/py-shinywidgets/","tags":["shiny","ipywidgets","web-development","dashboard","interactivity","widgets","rstudio"],"install":[{"cmd":"pip install shinywidgets","lang":"bash","label":"Install core library"},{"cmd":"pip install shinywidgets ipywidgets ipyleaflet","lang":"bash","label":"Install with common dependencies (e.g., ipyleaflet)"}],"dependencies":[{"reason":"Core framework for building applications.","package":"shiny","optional":false},{"reason":"The underlying interactive widget framework.","package":"ipywidgets","optional":false},{"reason":"Required for `altair` and `plotly` integrations since `shinywidgets` v0.5.0.","package":"anywidget","optional":true}],"imports":[{"symbol":"output_widget","correct":"from shinywidgets import output_widget"},{"symbol":"render_widget","correct":"from shinywidgets import render_widget"}],"quickstart":{"code":"from shiny import App, ui, render\nfrom shinywidgets import output_widget, render_widget\nimport ipywidgets as widgets\n\napp_ui = ui.page_fluid(\n    ui.h2('Shiny + ipywidgets'),\n    output_widget('my_slider'),\n    ui.output_text('slider_value'),\n)\n\ndef server(input, output, session):\n    @render_widget\n    def my_slider():\n        return widgets.IntSlider(min=0, max=100, value=50, description='Slider:')\n\n    @output\n    @render.text\n    def slider_value():\n        return f'Slider value: {input.my_slider()}'\n\napp = App(app_ui, server)","lang":"python","description":"This example demonstrates how to integrate an `ipywidgets.IntSlider` into a Shiny application. The `output_widget` function creates a placeholder in the UI, and the `@render_widget` decorator on the server side defines the `ipywidget` to be rendered. The widget's value can be accessed via `input.widget_id()` just like standard Shiny inputs."},"warnings":[{"fix":"If automatic cleanup is required, consider re-evaluating widget initialization placement or explicitly managing the widget's lifecycle with `widget.close()` within the effect.","message":"Widgets initialized inside a `reactive.effect()` are no longer automatically removed when the effect invalidates. This change requires manual management of widget lifecycle if automatic cleanup was previously relied upon.","severity":"gotcha","affected_versions":">=0.6.0"},{"fix":"Ensure you `pip install anywidget` and, if using Plotly, `pip install plotly>=6.0.0`.","message":"For `altair` and `plotly` integrations, `anywidget` is now a direct dependency and must be installed separately. Additionally, `plotly` versions prior to 6.0.0 might be incompatible.","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Upgrade `shinywidgets` to version `0.7.1` or newer (`pip install --upgrade shinywidgets`).","message":"`anywidget`-based widgets (e.g., Plotly, Altair) may fail to initialize or update correctly with `websockets` versions 16.0 or higher due to a fix introduced in `shinywidgets` v0.7.1.","severity":"gotcha","affected_versions":"<0.7.1"},{"fix":"Upgrade `shinywidgets` to version `0.7.2` or newer (`pip install --upgrade shinywidgets`) to ensure proper widget cleanup.","message":"In `shinywidgets` versions before 0.7.2, widget cleanup might not occur correctly if the widget was created inside a render output's context that differs from the current context, potentially leading to resource leaks or unexpected behavior.","severity":"gotcha","affected_versions":"<0.7.2"}],"env_vars":null,"search_vec":"'0.8.0':56 'activ':60 'address':64 'allow':35 'app':51 'applic':17 'bridg':19 'cadenc':62 'capabl':26 'compat':65 'current':53 'dashboard':79 'develop':78 'direct':47 'ecosystem':41 'emb':38 'exist':39 'facilit':5 'fair':59 'framework':32 'gap':21 'integr':3 'interact':9,25,80 'ipyleaflet':43 'ipyvolum':46 'ipywidget':12,28,70,75 'like':42 'new':67 'often':63 'plot':71 'plotly.graph_objects.figurewidget':44 'python':16 'reactiv':31 'releas':61 'render':7 'rich':24 'rstudio':82 'shini':1,14,34,50,74 'shinywidget':4 'use':10 'user':36 'version':54,68 'web':77 'web-develop':76 'websocket':73 'widget':2,40,81 'within':13","created_at":"2026-04-17T01:23:02.261649+00:00","updated_at":"2026-04-17T01:23:02.261649+00:00","problems":[{"fix":"Upgrade `shinywidgets` to version `0.5.1` or higher: `pip install --upgrade shinywidgets`.","cause":"This error occurred in `shinywidgets` versions prior to 0.5.1 due to an internal handling issue with widget representation, particularly with certain `ipywidgets`.","error":"AttributeError: object has no attribute '_repr_mimebundle_'"},{"fix":"Ensure `pip install anywidget plotly>=6.0.0` and `pip install --upgrade shinywidgets` (to at least v0.7.1) are executed.","cause":"Common causes include missing `anywidget` dependency, an outdated `plotly` version (pre-6.0.0), or incompatibility with `websockets>=16.0` in `shinywidgets < 0.7.1`.","error":"Plotly graph not rendering or failing to update in Shiny app."},{"fix":"Upgrade `shinywidgets` to version `0.5.0` or higher: `pip install --upgrade shinywidgets`.","cause":"This issue was specific to `ipyleaflet` integration in `shinywidgets` versions prior to 0.5.0, related to how closed widget objects were handled.","error":"ipyleaflet erroring out when attempting to read the .model_id property of a closed widget object."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.8.1","cli_name":"","cli_version":null,"type":"library","homepage":"https://rstudio.github.io/py-shinywidgets/","github":"https://github.com/rstudio/py-shinywidgets","docs":"https://github.com/rstudio/py-shinywidgets/","changelog":null,"pypi":"https://pypi.org/project/shinywidgets/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["web-framework"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":null}}