Creating a Sparkling Dashboard: Enhancing Browser Zoom with CSS

Trying to incorporate a zoom feature into my ShinyDashboard to enhance the layout aesthetics at 80% zoom level on web browsers.

Came across an SO article for a Shiny app, but unfortunately, it doesn't translate well to Shinydashboard. Applying the CSS code results in excessive white space.

Link to SO Article: Zoom out shiny app at default in browser

Here's a simple example of the code:

library(shiny)
library(shinydashboard)

header <- dashboardHeader()
sidebar <- dashboardSidebar()
body <- dashboardBody(
  tags$style("
              body {
             -moz-transform: scale(0.8, 0.8); /* Moz-browsers */
             zoom: 0.8; /* Other non-webkit browsers */
             zoom: 80%; /* Webkit browsers */
             }
             "),
  "test")

ui <- dashboardPage(header, sidebar, body)

server <- function(input, output, session) {}

shinyApp(ui, server)

Answer №1

Perhaps this could potentially resolve the issue you're experiencing - consider including a height parameter within your application.

library(shiny)
library(shinydashboard)

header <- dashboardHeader()
sidebar <- dashboardSidebar()
body <- dashboardBody(
  fluidPage(
   tags$head(tags$style(HTML('
                         .content-wrapper,
                        .right-side {
                          background-color: #ffffff;
                          height: 1200px;
                         }

                body{ 
                -moz-transform: scale(0.8, 0.8); /* Moz-browsers */
                zoom: 0.7; /* Other non-webkit browsers */
                 zoom: 70%; /* Webkit browsers */
                }
                          '))),
  "test")
  )

ui <- dashboardPage(header, sidebar, body)

server <- function(input, output, session) {}

shinyApp(ui, server)

Answer №2

library(shinyjs)

runjs(
  "document.body.style.zoom = 0.8;
  var elem = document.getElementsByClassName('wrapper');
  elem[0].style.height = '125vh';"
)

This code snippet adjusts the size of content in a shinydashboard by zooming out and stretching it to fill the screen. However, I advise against using this method as it can cause issues with interactive map features, leading to problems such as map tiles not rendering properly and map markers moving unexpectedly. These bugs may vary across different browsers, making it a risky approach.

While this solution may work in some cases, it is important to note that tweaking the viewport height value and adjusting other dashboard elements may be necessary to achieve the desired look.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Filtering data without displaying every item as the default setting

I am looking to create a customized data filter that only displays items when a specific category is chosen. Most filters online display all items by default, but I want one that remains hidden until I choose to reveal them. If anyone has a tutorial or c ...

Is there a way to display both the label and the input field in a single line?

How do I align the label and input on the same line with a spacing of 1.5cm between them? I tried using this resource, where it mentioned using form-inline but wasn't successful in achieving the desired layout. https://i.sstatic.net/7MW2H.png Appre ...

Trigger an "onMouseMove" event when the "pointer-events-none" css property is applied to fire

Currently, I am dealing with a React Component that contains an absolutely positioned div overlaying other content within my application. This particular div is utilized to trigger react's onMouseMove event. My objective is to apply the CSS value poi ...

Can CSS rules be inserted outside of the Header section?

Question: Can CSS styles be declared outside the “HEAD” element of an “HTML” page ? While working within a CMS where access to the header tag is restricted, is there a method to include CSS rules within the <BODY> of the ...

Center the content of the HTML body

Despite my best efforts, I seem to be making a mistake somewhere. While creating a bootstrap website at , the site appears well and aligned in the center. However, when I try to adjust the screen size to less than 850px or even smaller, all the content shi ...

Gradually blend the section of the picture with an image banner after 20 seconds

I have a background image that rotates every 20 seconds, fading in and out. The images consist of a logo at the top-left corner and a person image at the right side from top to bottom. However, I want only the person image to fade in and out while keeping ...

Adjust the Division's Width to be 20% of the Total Page Width Excluding Margins

https://i.sstatic.net/T0nKq.png I need to create a menu page with 5 equal columns, but I'm facing an issue with the layout. Here's my current CSS for the yellow divs: width:20%; height:100vh; background-color: yellow; display:inline-block; In ...

Using a purrr loop to dynamically assign the name of a data frame as the title for a gg

Looking to create histograms that display data overlap by name (A, B, C) using two different datasets. I have developed a custom function to utilize ggplot with map2 for this purpose. The desired outcome is to have the graphs titled with the names of each ...

Several radial progress charts in JavaScript

While attempting to recreate and update this chart, I successfully created a separate chart but encountered difficulties with achieving the second progress. The secondary chart <div id="radial-progress-vha"> <div class="circle-vha ...

Header logo not showing up on webpage

While working on a website template for a friend, I encountered an issue when uploading the site. The logo image was displaying perfectly fine on my local drive, but once uploaded, it showed as a broken image icon on the live website. Here is the code sni ...

Obtaining a subset of a character string in R

I have a dataset containing approximately 200,000 rows and I am looking to extract a specific section of text from one of the columns. I have attempted using methods like split and str_split but have not been able to achieve the desired result. What I nee ...

Position the "SHARE" button at the exact center of both the vertical and horizontal axes of an image (activating when the cursor hovers over it)

I'm currently working on a project and I really like the design on Fancy: . When you hover over an image, the background darkens and a button appears in the front. What I want to achieve is similar, but with a SHARE button instead. I have the image d ...

Expanding rows into columns: condensing data

Hello everyone, this is my first time posting here. I'm just starting out with R and I have a question regarding data transformation. Here is the format of the dataframe I am working with: date value 2018-01-01 123 2018-02-01 12 2018-03-01 ...

Discovering the solution to creating a responsive element grid using only CSS: (8-1) - (4-2) - (2-4) - (1-8)

My responsive website includes the following HTML code: <div id="fpma"> <span class="fpm"></span> <span class="fpm"></span> <span class="fpm"></span> ...

Make the background image within a button stretch to completely cover the button

I need assistance with creating a button that has a large image as its background. The challenge I'm facing is that the image fits vertically within the button, but horizontally it repeats unless I use 'no-repeat', which leaves empty space i ...

"Using `float: left` and a right-to-left direction in a cascading style sheet

What is the best way to change float:left to float:right for right-to-left language viewing on the same JSP file? ...

Hide the class containing specific text content by setting the display to none

I am currently working on a Joomla CMS Website that is quite large in scale. Issue: My main problem right now is figuring out how to hide a particular menu tab across the entire site. Unfortunately, this specific menu item does not have a unique identifie ...

Curved edges conceal excess content + alter (Works in Firefox & Safari, but not in Chrome or Opera)

Trying to create rounded corners for a div to mask its children's content led me to a solution I found in this question. However, it appears that the solution does not work when the children elements are transformed. The following http://jsfiddle.net ...

What strategies can be used to adjust node positions in ggraph in order to create diverse network visualizations?

I am facing a challenge in creating networks with fixed node positions that can vary from one network to another. My goal is to generate multiple graphs with a key node positioned centrally and the other nodes arranged around it. This allows me to compare ...

An issue occurred while executing the rscript

On my Mac running OS X El Capitan 10.11.5, I have a Homebrew version of R installed and have been using rscript successfully for the past few weeks. However, this morning when I attempted to run a script using rscript file.r, I encountered the following er ...