# Plotly visuals full screen

**URL:** <https://community.plotly.com/t/plotly-visuals-full-screen/86229>\
**Category:** 📊 Plotly Python\
**Created:** [July 31, 2024, 2:27pm UTC](https://community.plotly.com/t/plotly-visuals-full-screen/86229 "2024-07-31T14:27:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![GabrielBKaram](https://avatars.discourse-cdn.com/v4/letter/g/e8c25b/32.png) [@GabrielBKaram](https://community.plotly.com/u/GabrielBKaram)\
**Post date:** [July 31, 2024, 2:27pm UTC](https://community.plotly.com/t/plotly-visuals-full-screen/86229/1 "2024-07-31T14:27:21Z")

</div>

Are we ever going to get a full screen option directly in the modebar of plotly visuals? it seems quiet tedious now to add buttons/modals to generate a full screen view of the plot.

---

<div class="post-metadata">

**Author:** ![AIMPED](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/aimped/32/21758_2.png) [@AIMPED](https://community.plotly.com/u/AIMPED)\
**Post date:** [July 31, 2024, 4:33pm UTC](https://community.plotly.com/t/plotly-visuals-full-screen/86229/2 "2024-07-31T16:33:23Z")

</div>

Hi @GabrielBKaram you could create a feature request on github for that. 🙌

---

<div class="post-metadata">

**Author:** ![techdhirendra](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/techdhirendra/32/29836_2.png) [@techdhirendra](https://community.plotly.com/u/techdhirendra)\
**Post date:** [November 27, 2024, 8:46am UTC](https://community.plotly.com/t/plotly-visuals-full-screen/86229/3 "2024-11-27T08:46:17Z")

</div>

Save following JavaScript code in assets folder of Dash application to add a custom button in modebar to each plotly graph to view in fullscreen mode.

```auto
//Script to show Plotly graph to fullscreen mode
//Dependence on Font Awesome icons
//Author: Dhirendra Kumar
//Created: 26-Nov-2024

function addToModbar() {
    const modeBars = document.querySelectorAll(".modebar-container");
    for(let i=0; i<modeBars.length; i++) {
        const modeBarGroups = modeBars[i].querySelectorAll(".modebar-group");
        const modeBarBtns = modeBarGroups[modeBarGroups.length - 1].querySelectorAll(".modebar-btn");

        if (modeBarBtns[modeBarBtns.length - 1].getAttribute('data-title') !== 'Fullscreen') {
            const aTag = document.createElement('a');
            aTag.className = "modebar-btn";
            aTag.setAttribute("rel", "tooltip");
            aTag.setAttribute("data-title", "Fullscreen");
            aTag.setAttribute("style", "color:gray");
            aTag.setAttribute("onClick", "fullscreen(this);");
            const iTag = document.createElement('i');
            iTag.className = 'fa-solid fa-maximize';
            aTag.appendChild(iTag);
            modeBarGroups[modeBarGroups.length - 1].appendChild(aTag);
        }
    }
}

function fullscreen(el) {
    elem = el.closest('.dash-graph');
    if (document.fullscreenElement) {
        if (document.exitFullscreen) {
            document.exitFullscreen();
        } else if (document.mozCancelFullScreen) { // Firefox
            document.mozCancelFullScreen();
        } else if (document.webkitExitFullscreen) { // Chrome, Safari and Opera
            document.webkitExitFullscreen();
        } else if (document.msExitFullscreen) { // IE/Edge
            document.msExitFullscreen();
        }
    }
    else {
        if (elem.requestFullscreen) {
            elem.requestFullscreen();
        } else if (elem.mozRequestFullScreen) { // Firefox
            elem.mozRequestFullScreen();
        } else if (elem.webkitRequestFullscreen) { // Chrome, Safari and Opera
            elem.webkitRequestFullscreen();
        } else if (elem.msRequestFullscreen) { // IE/Edge
            elem.msRequestFullscreen();
        }
    }
}

window.fetch = new Proxy(window.fetch, {
    apply(fetch, that, args) {
        // Forward function call to the original fetch
        const result = fetch.apply(that, args);

        // Do whatever you want with the resulting Promise
        result.then((response) => {
            if (args[0] == '/_dash-update-component') {
                setTimeout(function() {addToModbar()}, 1000)
            }})
        return result
        }
})

```

---

<div class="post-metadata">

**Author:** ![GabrielBKaram](https://avatars.discourse-cdn.com/v4/letter/g/e8c25b/32.png) [@GabrielBKaram](https://community.plotly.com/u/GabrielBKaram)\
**Post date:** [December 12, 2024, 4:01pm UTC](https://community.plotly.com/t/plotly-visuals-full-screen/86229/4 "2024-12-12T16:01:18Z")

</div>

hi @techdhirendra , i added this in the js file but i still cannot see fullscreen in modebar
