Creating an interactive R Shiny application with custom CSS styling and a modal

I am encountering an issue when trying to incorporate a modal dialog with a specific CSS style within a R Shiny app. Individually, I can successfully implement a modal dialog without the CSS style and apply the CSS style without any issues. However, when attempting to display the modal dialog alongside the CSS style, the modal dialog fails to appear.

To replicate this issue, you can utilize the following code. The CSS stylesheet I am using is 'flatly' from and should be saved in a subdirectory named www. To observe the different outcomes, you can comment and uncomment the line theme = "bootstrap-flatly.css":

shinyApp(ui=fluidPage(
  theme = "bootstrap-flatly.css",
  h1("Heading"),
  div("Some text"),
  selectInput("selectInput", "SomeInput", c(1,2,3), selected = NA, multiple = TRUE),
  actionButton("print", "print")
),
server <- function(input, output){
  showModal(modalDialog(
    title = "My message",
    easyClose = FALSE,
    footer = actionButton("closemodal", "OK")
  ))
  observeEvent(
    {
      input$closemodal
    },{
      removeModal()})
  observeEvent(input$print, reactiveValuesToList(input) %>% print)
}
)

I am seeking assistance in understanding this behavior and would appreciate any guidance on how to successfully apply the CSS style to my modal dialog.

Answer №1

This issue has been discussed on this thread, but the suggested solution did not work for your specific case - attempting to modify the CSS file by adding .modal {z-index: 1050;}.

As an alternative, you can utilize the shinythemes package, which offers the flatly theme without the need for any downloads.

library(shiny)
library(shinythemes)

shinyApp(ui=fluidPage(
  theme = shinytheme("flatly"),
  h1("Heading"),
  div("Some text"),
  selectInput("selectInput", "SomeInput", c(1,2,3),selected = NA, multiple = TRUE),
  actionButton("print","print")
),
server <- function(input,output){

  showModal(modalDialog(
    title = "My message",
    easyClose = FALSE,
    footer = actionButton("closemodal", "OK")
  ))

  observeEvent(
    {
      input$closemodal
    },{
      removeModal()})
  observeEvent(input$print, reactiveValuesToList(input) %>% print)
}
)

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

How can one element be made to rely on the presence of another element?

I'm currently working on my portfolio website and encountering an issue. Whenever I hover over an image of a project, the image expands in size, becomes less transparent, and a description of the project pops up. However, I would like to include a lin ...

Exploring Data with Polar Plots using Plotly in R

Recently, I've been utilizing the plotly package in R to generate a polar plot. However, I have encountered an issue where the output appears somewhat peculiar. Despite seeing individual points, it fails to enclose the max points within the geometric ...

I am interested in creating a header that remains static

Currently, I am attempting to create a header that has a freezing effect. My goal is to have a banner at the top with a navigation menu underneath it. When scrolling down, I want the banner to disappear but have the navigation menu remain frozen at the top ...

Issues with inconsistent behavior of the select option in a form

Having some trouble with my form code. When I checked the web page, there seems to be an extra element that shouldn't be there. You can view the webpage https://i.sstatic.net/pu4ef.jpg. Inspecting it in browser developer mode, I found this extra eleme ...

Safari Mobile not rendering absolute positioning correctly

Our website www.anahatainternational.org has a functioning search section that is displaying correctly on Firefox, Chrome, and Safari browsers. However, we have encountered an issue with the mobile version of Safari where the search section appears in the ...

What could be causing my div elements to not appear on the page?

Hey there, this is my debut post here so bear with me on the formatting. I'm currently working on a project and encountering some hurdles with my divs. Even though I've left space for them, I just can't seem to get my divs (or cards) to disp ...

Achieving full width for the elements in a row with Flexbox: A step-by-step guide

I am dealing with a flexbox grid that contains random width images: https://i.stack.imgur.com/pfPeU.jpg I want to stretch the elements in each row to full width to eliminate any white space - Is there a way to achieve this using CSS? justify-content do ...

What is the process for adding and merging two data frames together?

I am working with two different sets of data: SET 1: ID com_alc_cd com_liv_cd com_hyee_cd A 1 0 0 B 0 0 1 D 0 0 0 C 0 1 0 ...

Customize the Grid Offset in CSS like BootstrapCSS Grid Offset

I am attempting to replicate the offset feature in Bootstrap's desktop grid system, where a class like .col-md-offset-3 creates an offset using margin-left. However, in my implementation found at this link, the CSS selector does not work as intended: ...

"Looking to spice up your website with a dynamic background-image

I've encountered a problem with my CSS code for the header's background image. Despite trying various methods to create a slideshow, nothing seems to be working. Can someone provide guidance? I have four banner images named banner1, banner2, bann ...

Connections between Wordpress websites and CSS styling

My inquiry consists of three parts: I am currently in the process of constructing a portfolio website using Wordpress, and I have encountered some peculiar links. For instance, on my about page, the link appears as localhost/AFolder/anotherfolder/ind ...

Tips for displaying an asp.net form using javascript functions

I am currently developing a login page in asp.net and have utilized a template from CodePen at http://codepen.io/andytran/pen/PwoQgO It is my understanding that an asp.net page can only have one form tag with runat="server". However, I need to incorporate ...

Place an element in a higher position than a slideshow

I recently encountered an issue where I was trying to place a png image above my slideshow. Despite trying various solutions, the image always appeared behind or on top without transparency. Based on the erratic display, it seems like the problem might be ...

Issue with displaying PDF files on Google Chrome due to a software glitch

Recently, I encountered a puzzling issue on Google Chrome. I am not sure if the error lies with Google or within my code. When I set the div as display: none; and then show it again, the PDF view only shows a grey background. However, if I zoom in or out, ...

What could be causing the header's height to remain unchanged when using a percentage for its size?

I'm having trouble creating a header that takes up 20% to 40% of the body. When I try using percentages, it doesn't work but it works fine with pixels. Can someone explain why percentages aren't working for this? *{ margin:0; padding: ...

Troubleshooting a live chat box for CSS alignment issues

Need help with aligning a live chat box on every webpage? Check out this example for reference: You can find my code here: https://jsfiddle.net/fn77d0de/2/ ...

Tips for aligning column components in a vertical position

My task is to align vertically the elements within multiple columns that include a headline, a description, and a button. By default, each element expands based on its content size https://i.stack.imgur.com/RJJP4.png However, I need all elements to be al ...

What are some techniques I can use to ensure my image grid is responsive in html/css?

If you want to check out the website, you can visit . The main goal is to create an image grid for a portfolio. It appears really nice on a 1080p screen, but anything below that seems messy and unorganized. Any assistance or suggestions on how to improve ...

Resource for building user interface components in Javascript

I need assistance with implementing a feature that involves scrolling through different text blocks and corresponding images. Users should be able to select a specific text block and have the associated image on the right scroll into view, similar to a car ...

Optimize flexbox navbar layout by eliminating unnecessary spacing between items

Greetings! As a novice in the world of web development, I must admit that I am facing some difficulties with my homework assignment. Despite my several attempts, I am unable to remove the spacing in the navbar on my university website clone project. It sim ...