Tips for customizing the sidebar menu in R Shiny to use an "angle-right icon" instead of the default "angle-left icon"

I am trying to modify the default arrow orientation (shown in the image), so that it points towards the right.

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

This is the current snippet of code:

      sidebarMenu(
        menuItem("Market data", tabName = "market data", icon = icon("users"), startExpanded = TRUE,
                 menuSubItem("Performance", tabName = "history", icon = icon("calendar-day")),
                 menuSubItem("SMP", tabName = "SMP", icon = icon("dollar-sign"))
        ),
        
        menuItem("Consumer 1", tabName = "consumer1", icon = icon("user"), startExpanded = FALSE,
                 menuSubItem("Consumption", tabName = "consumption", icon = icon("history")),
                 menuSubItem("Profile", tabName = "profile", icon = icon("poll-h")),
                 menuSubItem("Forecast engine", tabName = "forecast", icon = icon("brain"))
        )

Any assistance will be greatly appreciated

Answer №1

General Tips

If you want to customize the default settings in shinydashboard, you'll need to identify the relevant CSS tags for these elements and then create your own custom CSS file to override the defaults.

Keep in mind, if you anticipate making numerous changes, the shinydashboard framework may not be the best fit for your needs.

Solution for Your Specific Query

Upon inspecting the browser, you'll notice that the arrows are controlled by the .fa-angle-left:before tag. The symbol displayed is defined in the CSS as follows:

.fa-angle-left:before{content:"\f104"}

To change it to a right arrow, you simply need to replace \f104 with \f105:

Referencing the documentation here, you can incorporate your custom CSS as displayed below:

  • Create the file www/custom.css in the same directory as your Shiny dashboard.
  • Add the following code snippet to the custom CSS file:
.fa-angle-left:before{content:"\f105"}

If you want the arrow to point downward after clicking, include the additional snippet below:

.sidebar-menu li.active>a>.fa-angle-left, .sidebar-menu li.active>a>.pull-right-container>.fa-angle-left {
    transform: rotate(90deg);
}
  • After completing these steps, insert the code below in your sidebarMenu:
tags$head(
          tags$link(rel = "stylesheet", type = "text/css", href = "custom.css")
        )

Example of Implementation

app.R

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(),
  dashboardSidebar(
    dashboardSidebar(
      sidebarMenu(
        tags$head(
          tags$link(rel = "stylesheet", type = "text/css", href = "custom.css")
        ),
        menuItem(
          "Market data",
          tabName = "market data",
          icon = icon("users"),
          menuSubItem("SMP", tabName = "SMP", icon = icon("dollar-sign"))
        )
      )
    )
  ),
  dashboardBody()
)

server <- function(input, output) {}

shinyApp(ui, server)

www/custom.css


.fa-angle-left:before{content:"\f105"}

.sidebar-menu li.active>a>.fa-angle-left, .sidebar-menu li.active>a>.pull-right-container>.fa-angle-left {
    transform: rotate(90deg);
}

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

Creating a tiny arrow using CSS

Can anyone advise on the best way to create a small arrow design using CSS? I have tried using a regular closing > arrow, but it's not quite what I'm looking for. https://i.stack.imgur.com/7uLMG.png ...

Managing varied PHP submissions using a single 'isset' declaration

I'm working on loading data from a MySQL database with PHP and displaying images in HTML. When a specific image is clicked, I want to show text associated with that image using MySQL/PHP. I'm looking for a way to achieve this without having multi ...

I'm having trouble using jQuery to access my element

Hi there, I am having trouble accessing my button on the page. When I try to click on it, nothing seems to happen. Can someone please help me out with this issue? $(document).ready(function() { $('#cart_inside').load('php/load_Cart.php&a ...

Using the onClick function to set attributes in React JS

I am currently working with 2 functions: addBookmark() and removeBookmark(). There is a variable called IsBookmarked that can be either true or false. In my JSX code related to bookmarks, it looks like this: {props.singleCompany.IsBookmarked ? ( ...

What could be hindering the animation of this button?

I found this snippet on a coding blog, where the design looked perfect: However, when I tried implementing it, the button displayed a static gradient instead of animated. Additionally, aligning the text in the center vertically seems to be trickier than e ...

Tips for creating a sidebar table of contents with CSS

I'm looking to design a webpage with a side bar table of contents (TOC) similar to the one found here: The current placement of the TOC on the HTML page is as follows: <h2>Table of Contents</h2> <div id="text-table-of-contents&quo ...

Tips for implementing arraybuffer playback in video tags

I have been exploring ways to convert images from an HTML canvas into a video. After much research, I just want to be able to select a few images and turn them into a video. By passing multiple images to a library engine, I am able to receive an array buff ...

Ways to position a single item in the middle of a multi-column layout

I need help with aligning dynamic images in a 2-column layout. What's the best way to center a single image or collapse the columns when there's only one image? Currently, the single image is always placed in the left column. Is there a CSS-only ...

Styling the background of a container in CSS using Bootstrap

Currently, I am utilizing bootstrap and trying to find an elegant solution for adding a background to my container. Specifically, I am working with the bootstrap class container, as opposed to container-fluid. The official Bootstrap documentation advises ...

What is the best way to add a box shadow to just one side of an element?

Is there a way to apply an inset box-shadow to only one side of a div? I am specifically referring to an inset shadow, not the usual outer box-shadow. For instance, in the JSFiddle below, you can observe that the inset shadow is visible on all four sides, ...

Tips on resolving JavaScript's failure to adjust to the latest HTML inputs

I'm working on a homepage where users can choose their preferred search engine. The issue I'm facing is that even if they switch between search engines, the result remains the same. I've experimented with if-then statements, but the selecti ...

Incorporate a Font Awesome icon into a Bootstrap 4 callout

I am having issues adding an icon to the left side of a Bootstrap 4 callout. Currently, the icon is appearing above the H4 heading. I would like the icon to be positioned on the left side before the message. I have attempted using .p:last-child but it doe ...

The 'function' is not defined in Edge and Explorer browsers

I am currently working on a web page in SharePoint and have encountered an issue where the onclick referenced function throws an error only in Internet Explorer 11 and Microsoft Edge. However, in Chrome, Firefox, and Opera, everything works perfectly fine. ...

a container holding two floating divs

I have been attempting to create two divs positioned side by side, with one containing content and the other acting as a sidebar. Both of these divs are contained within another larger container div. Despite my efforts, I have not been successful in achiev ...

Inject HTML entities, escaped for CSS, dynamically using JavaScript

My goal is to dynamically generate a list of HTMLElements with unique data-* attributes that correspond to various HTML Entities. These attributes will then be utilized by CSS to display content in pseudo elements like this: li:after { content: attr(dat ...

Troubleshooting issue with Bootstrap slider: CSS display problem

After downloading the Bootstrap slider from this link: https://github.com/seiyria/bootstrap-slider, I navigated to \bootstrap-slider-master\dist and transferred the bootstrap-slider.js and bootstrap-slider.min.js files to my js folder. Additional ...

modify pseudo element's style in Angular based on a particular condition

I am trying to change the style of :before based on a condition. I attempted to implement the solution provided at , but it did not work as expected. Here is my code: .sender:before { content: ""; width: 0px; ...

Personalizing the fileTemplate selection in FineUploader

My English is not the best, so apologies in advance. I'm struggling to customize the FineUploader FileTemplate option. I don't want to use fineUploaderBasic; I want total customization. Initially, I managed to hide the file name and size after a ...

Utilizing PHP and AJAX to Extract Information from a MySQL Database

My goal is to fetch data from a MySQL database hosted on a webserver and display it in an HTML table. I've been following an example on W3Schools, but I'm facing issues retrieving the data successfully. Here is the source code: (HTML) <html& ...

The function given to requestAnimationFrame is not being triggered as expected

I have successfully implemented an infinite loop animation using setInterval. However, I want to enhance the performance by switching to requestAnimationFrame(). Unfortunately, the function supplied to requestAnimationFrame() is not being called for some r ...