What is the best method for eliminating shading on sub-tabs in R Shiny?

Currently, I am in the process of developing a user-friendly interface with senior tabs and sub-tabs underneath to guide users through various options. To better assist users in navigating these choices, I have implemented a system where inactive senior tabs are shaded while active senior tabs remain unshaded. I would like to extend this design principle to the sub-tabs as well, as illustrated in the accompanying image. Are there any suggestions on how I can achieve this? This inquiry is related to my previous post on Stack Overflow, where I utilized code from the initial response:

https://i.sstatic.net/N7amP.png

I am open to any ideas for enhancing the visual appeal of the tabs as well!

Sample Code:

library(shiny)
library(shinyjs)

ui <-shinyUI(fluidPage(
  h1("Tabs"),
  tags$style(HTML("
    .tabbable > .nav > li > a                  {background-color: #E0E0E0; color:black}
    .tabbable > .nav > li[class=active]    > a {background-color: white;color:black}
  ")),
  tabsetPanel(
    tabPanel("Tab 1", div(style = "margin-top: 5px"),
             tabsetPanel(
               tabPanel("Tab 1 subtab A"), 
               tabPanel("Tab 1 subtab B")
               )
             ),
    tabPanel("Tab 2", div(style = "margin-top: 5px"),
             tabsetPanel(
               tabPanel("Tab 2 subtab A"), 
               tabPanel("Tab 2 subtab B")
                )
            ),
    tabPanel("Tab 3",h2("senior tab 3")), 
    tabPanel("Tab 4",h2("senior tab 4")),
    tabPanel("Tab 5",h2("senior tab 5")),
    tabPanel("Tab 6",div(style = "margin-top: 5px"),
             tabsetPanel(
               tabPanel("Tab 6 subtab A"), 
               tabPanel("Tab 6 subtab B")
             )
             )
  )
))
server <- function(input, output) {}
shinyApp(ui=ui,server=server)

Answer №1

It appears you are on the right track, but I would recommend enhancing the subtabs with different shading for better visibility.

This will help emphasize the active subtab while also indicating it is part of the selected "Senior Tab."

To achieve this, simply introduce a new style:

.tabbable .tabbable li a {background-color: #FAFAFA;}
. Make sure to adjust the shade color as needed.

Here is a complete example below:

library(shiny)
library(shinyjs)

ui <-shinyUI(fluidPage(
  h1("Tabs"),
  tags$style(HTML("
    .tabbable > .nav > li > a                  {background-color: #E0E0E0; color:black}
    .tabbable > .nav > li[class=active]    > a {background-color: white;color:black}
    .tabbable .tabbable li a {background-color: #FAFAFA;}
  ")),
  tabsetPanel(
    tabPanel("Tab 1", div(style = "margin-top: 5px"),
             tabsetPanel(
               tabPanel("Tab 1 subtab A"), 
               tabPanel("Tab 1 subtab B")
             )
    ),
    tabPanel("Tab 2", div(style = "margin-top: 5px"),
             tabsetPanel(
               tabPanel("Tab 2 subtab A"), 
               tabPanel("Tab 2 subtab B")
             )
    ),
    tabPanel("Tab 3",h2("senior tab 3")), 
    tabPanel("Tab 4",h2("senior tab 4")),
    tabPanel("Tab 5",h2("senior tab 5")),
    tabPanel("Tab 6",div(style = "margin-top: 5px"),
             tabsetPanel(
               tabPanel("Tab 6 subtab A"), 
               tabPanel("Tab 6 subtab B")
             )
    )
  )
))
server <- function(input, output) {}
shinyApp(ui=ui,server=server)

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 the onclick attribute be modified in an HTML document?

I am looking to update the data-pro-bar-percent attribute of a progress bar from 80 to 100 when a specific link is clicked. The change in attribute needs to be as follows: data-pro-bar-percent="80" --> data-pro-bar-percent="100" This is the current HT ...

Having difficulty scrolling down in a section with 100% height on iOS devices

Currently facing an issue with a website I am creating for my wedding invitation. The top section is set to have a 100% height and requires scrolling to view the rest of the content. While it functions perfectly on FireFox / Chrome on my computer, there s ...

CSS image cropping is a technique used to adjust the size

I have successfully created a grid of images with two columns, but I'm facing an issue with a portrait image disrupting the layout. I am looking for a way to adjust or "crop" the image so it matches the height of the landscape ones. I attempted to use ...

Take the attention away from the canvas

Is there a way to shift focus away from the canvas and onto input fields in my HTML code? Right now, the canvas is holding onto focus even when I'm clicking on text inputs. This prevents me from typing anything into them. Ideally, I'd like for t ...

Submitting an ajax form with the use of the symbol '&'

I am currently working on a form submission using the .ajax() method. Within my script, I have the following code: data: dataString, The variable dataString is composed of: var list = $('.listsummary').val() The listsummary class is assoc ...

Animate the height transition of contenteditable after a line of text is added (using shift+enter) or removed

Currently, the contenteditable attribute is being utilized on the <div> tag to enable autogrow functionality similar to a textbox. Additionally, there is an attempt to incorporate a height transition. While most aspects are functioning correctly, the ...

Display web content using ASP.NET Razor cshtml files

I am currently working on a web application developed with ASP.NET 4.6.1 and utilizing the Razor view engine. Is there a way to trigger a command that will convert all my template files (.cshtml files) into static HTML? For specific stages in my build pro ...

Reset the value of the input type file when the modal is closed and ensure that the Save All Changes button is deactivated

Hey there! Working on a simple project and trying to incorporate a neat trick in my app. I want to achieve the following: Clear the input type file value when the modal is closed. Essentially, if the user decides to cancel the upload and closes the modal, ...

"Flaticon icons display properly when stored on a local server, but encounter issues when accessed online

Working on a website, I have incorporated numerous icons into the design. Despite organizing the files effectively, I am struggling to identify any potential issues. As a beginner in this field, I continue to learn and grow. ...

Ways to target only the adjacent div

My goal is to target only the next div with the class name indented. Each indented div should have the same id as the <li> element right before it. Currently, I want each div with the class name indented to have the id of the previous <li>. He ...

Gather information using the nth-child or css_selector methods in selenium using python

Exploring the realms of Python and Selenium, I have set my sights on data extraction from . Specifically, I am interested in retrieving the market cap and 24-hour volume values. The HTML snippets for these are outlined below. <div id="__next"& ...

Implementing two background images and dynamically adjusting their transparency

With the challenge of loading two fixed body background-images, both set to cover, I encountered a dilemma. The text on the page was extending below and scrolling, along with top and bottom navigation icons. As expected, the second background covered the f ...

How can I pass a specific value, rather than the entire array, in a ReactJS dropdown menu?

I am facing a problem where the entire array is being passed as an argument when I call onchange after getting correct values in the dropdown. Instead of only receiving the selected value, e contains the whole array. Here is the code snippet that demonst ...

Steps to click on a link within a span element contained within an anchor element with a specific class using XPath

When using xpath, sélénium is not recognizing the element. What would be the correct xpath to use? HTML: <a class="xmi" onclick="this.focus();return false; "href="#"> <span title="">SITE A</span> </a> XML locator file: <do ...

What is the best way to ensure that three images stretching across the entire width of the website are responsive?

I am looking to showcase 3 images across the full width of my website, with each image taking up one-third of the space. I want these images to be responsive and adjust accordingly to different screen sizes while maintaining their aspect ratio. Do you have ...

What is the best way to align my Dropdown text to the left?

Is there a way to align my Dropdown and parent submenu text to the left, while keeping my tab text always justified to the right? Below is the code snippet: <!doctype html public "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/ ...

serving JSON and HTML responses using a PHP script

After searching through the questions here, I couldn't find a solution. As someone new to PHP and jQuery, I appreciate your patience as I explain my issue. My goal is to send an ajax request using jQuery to a script that runs a mysql query on data fr ...

Strange format issue with R data output

I have a set of function results in R that I need to export in order to visualize them in Gephi. There are 79,552 pairs listed in the following format: [[79549]] [1] 22 26 [[79550]] [1] 41 26 [[79551]] [1] 34 26 [[79552]] [1] 25 26 I need to export t ...

The link text does not appear in black color

Can anyone assist in modifying this code snippet? I'm trying to make the text appear black, but it's showing up as light grey on the Dreamweaver preview screen even though the CSS says it should be black. View Fiddle Below is my HTML code: < ...

Creating a list in R to store multiple dataframes

Is it possible to create an empty list in R that can later be populated with data frames, even if the dimensions of the data frame are unknown? Here's an example scenario: Let's say 'combined' is a data frame, and 'year_wave' ...