Glistening: A variety of designs for textInputs and selectInputs

I am working on styling 2 textInput and 2 selectInput functions, one on a dark background sidebar and the other inside a white bsModal. I want to style them differently. Is there a way to keep the sidebar elements styled one way and change the font and border color for the bsModal elements?

Code:

## Shiny 
library(shiny)
library(shinydashboard)
library(shinyBS)

ui <- dashboardPage(
  ## Header ----
  dashboardHeader(
    disable = TRUE
  ),

  ## Sidebar ----
  dashboardSidebar(
    sidebarMenu(
      div(style = "border-left-color: #1e282c; padding: 10px", 
      menuItem(text = div(HTML("<left>Search</left>")),
               tabName = "search",
               icon = icon("search", "fa-2x"))
    )
  )
  ),

  ## Body ----
  dashboardBody(
    ## when header is disabled need to compensate for the missing 50px 
    ## to avoid empty space on the bottom
    tags$script('window.onload = function() {
                function fixBodyHeight() {
                var el = $(document.getElementsByClassName("content-wrapper")[0]);
                var h = el.height();
                el.css("min-height", h + 50 + "px");
                };
                window.addEventListener("resize", fixBodyHeight);
                fixBodyHeight();
                };'),

    tags$style(HTML(
      "
      .well{
  background-color: #222C3C;
  color: #FFFFFF;
      }
.form-control {
  background-color: transparent;
  border: 0px;
  border-bottom: 1px solid #ffffff;
  color: #ffffff;
}

.selectize-input{
  background: transparent;
}

.selectize-input.items.not-full.has-options {
  border: 0px;
  border-bottom: 1px solid #ffffff;
  border-radius: 0;
} 

.selectize-dropdown, .selectize-input, .selectize-input input{
  color: #FFFFFF;
}
.selectize-control.multi .selectize-input > div{
  background: rgb(9, 231, 178, 0.3);
  color: #ffffff;
}

.selectize-dropdown-content {
  background: #1B2431;
  color: #ffffff;
  border-radius: 4px;
}

.selectize-input.full{
  background-color: transparent;
  color: #FFFFFF;
  border: 0px;
  border-bottom: 1px solid #ffffff;
  border-radius: 0;
}

.selectize-input, .selectize-control.single, .selectize-input.input-active{
  background: transparent !important;
}
      "

    )),

    # includeCSS("www/style.css"),

    tabItems(
      tabItem(
        tabName = "search",
        sidebarLayout(
          sidebarPanel(
            tabsetPanel(
              tabPanel(div("Search task"),
                       textInput("searchTextIn", HTML("<i class='fa fa-search'></i> KEYWORDS"), value = ""),
                       selectizeInput("productFilter", HTML("<i class='fa fa-share-alt gly-rotate-135'></i> PRODUCT OR COMPONENT"),
                                      choices = c("A", "AAA", "B", "BBBBBB", "C", "CCCCCC"),
                                      multiple = TRUE,
                                      selected = c("A", "AAA")), 
                                      actionLink("saveToGroup", HTML("<u> Save to group </u>"), style = "color: #d3d3d3cf"),
                                      width = 3)
              )),
          mainPanel(
            bsModal("saveToGroupPopup", "Save to group", "saveToGroup",
                    div(selectizeInput("saveToGroupSelection",
                                       "Add this search to a search group:",
                                       choices = c("Category A", "Category B", "Category C", 
                                                   "Batman"),
                                       selected = NULL,
                                       multiple = TRUE,
                                       options = list(maxItems = 1))),
                    textInput("saveToGroupNew", label = NULL, value = "", 
                              placeholder = "Create new…")
            )
          )
        )
      )
    )
  )
)



server <- function(input, output) {}

shinyApp(ui = ui, server = server)

Answer №1

Transform the appearance of your input fields using glamor. With glamor, you can create CSS styles within your JavaScript code by using conditional statements. By passing a boolean variable alongside a class, you can determine the styling of the text field based on the value of that variable.

const descDiv = **isDark** => css({
    color: isDark ? color.white : colors.gray,
    marginBottom: isDark? '0rem' :'1rem',
    letterSpacing:isDark ? '0px' :'-0.6px', //if isDark true 0px else -0.6px
    width:isDark? '10rem' :'13.5rem'
});

Answer №2

I found a solution that worked well for me when styling textInput. It was actually quite simple, all I had to do was add the following to my css:

textInput(id, "")
tags$style(HTML("
#id.form-control{color:gray;}
"))

Styling the selectize input was a bit more complex:

selectizeInput(id, ....)
tags$style(HTML("
#id + div>.selectize-input.items.not-full.has-options{border-bottom: 1px solid #F2F2F2;}
#id + div>.selectize-dropdown, #id+ div>.selectize-input, #id+ div>.selectize-input input{ color: gray;}
#id + div> div> .item {color: gray;}
"))

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

Adjust the alignment of cells within a table

Excuse my lack of knowledge, but CSS is still new to me. I'm attempting to align two elements next to each other using display: table. However, the element on the right seems to be lower than the one on the left, and I can't figure out why. . ...

Creating CSS wrappers around div elements of varying sizes

I am looking for a way to "wrap" different divs of varying sizes, similar to how Microsoft Word wraps text around an image. I have a simplified structure outlined below: <div id = "div1"></div> <div id = "div2"></div> <div id = ...

I can't seem to get my SCSS files to load properly on GitHub HTML pages, and I

Just starting out in the world of programming and decided to showcase my portfolio site on GitHub. While my index page is displaying correctly, I'm encountering issues with some images and all of my SCSS files not showing up. Any assistance or guidanc ...

What is the best way to delete a CSS class from a specific element in a list using React?

I need to implement a functionality in React that removes a specific CSS class from an item when clicking on that item's button, triggering the appearance of a menu. Here is my code snippet. import "./Homepage.css" import React, { useState, ...

Does CSS Horizontal Padding Percentage Stop Relative to Element Once Maximum Width is Reached?

I'm currently in the process of developing my latest portfolio website at and I'm facing a perplexing padding dilemma that has left me stumped. The approach I'm taking with the layout involves each row of content consisting of both an outer ...

Problem with traversing from parent to children elements using jQuery selectors

<form data-v-c4600f50="" novalidate="novalidate" class="v-form"> <div data-v-c4600f50="" class="pr-2" question="Top Secret4"> <div data-v-c4600f50="" f ...

How can I align a mapped button to appear on the opposite side of the data using Tailwind CSS?

I've been struggling to find a straightforward solution to this issue for a while now. Let me break it down - I need to display some data on the left side of a post card component with a button located right next to it. Here's an illustration: ...

Unable to get CSS to function properly on website

I am having trouble getting my text to format properly on my web page. I have defined rules in my style sheet to center an object on the screen, but it's not working as expected. Here is the code for my web page: body { text-align: center; } h1 { ...

Creating a seamless vertical marquee of several images that continuously scroll from bottom to top without interruption can be achieved by following these

Currently, I am seeking to design a mobile-friendly HTML page that features a border with multiple color images moving smoothly from bottom to top on both the right and left sides of the mobile screen. The transition should be seamless without any gaps o ...

Ways to define a variable based on a CSS class attribute?

I need help figuring out how to create a variable in my script that is defined by the width attribute of a CSS class. The snippet I have currently doesn't seem to work as expected. var dist = $('.nav').css(width()); The goal of my script i ...

Injecting PHP variables into CSS code right from a PHP file

$a = "ABCD"; ?> <link rel='stylesheet' type='text/css' href='others.php' /> <style> .page-title { text-indent: -9999px; line-height: 0; } .page-title:afte ...

What are the steps to generate a production build directory in a React project?

Currently, I am developing a website utilizing react for the frontend and node.js for the backend. However, I'm unsure of how to deploy it to the live server. After conducting some research, I learned that I need to create a build folder. To provide a ...

the child div within a Bootstrap 3 column is not being properly styled

Experiencing a strange issue with a relative div within a column in Bootstrap 3. Here's my code: <div class="col-lg-6"> <div class="large" style="background: url(img/bg.jpg);"> <h1 class="grid-header">Content 1</h1> ...

Is there a way to adjust the size of a table display to ensure that both vertical and horizontal scroll bars are constantly visible?

[edits added below per the request to see code. Edits also added to the original post to clarify the ask - marked in bold] My application features a broad table with the potential for many rows, generated by django-tables2 using the bootstrap5-responsive ...

What is the best way to ensure that all inner divs occupy the full height of their parent div?

I am seeking a solution to make all child divs fill the full height of the parent div without specifying a fixed height. Ideally, I would like them to adjust to the height of the tallest child div. However, if the only way to achieve this is through JS, I ...

Aligning content within an <a> container

I am in the process of creating a square box that is clickable and will redirect users to another page. To achieve this functionality, as well as implement hover effects later on, I am utilizing the < a > element. Below is the HTML markup: <a id ...

Preventing clashes in namespaces while incorporating Bootstrap into a plugin for WordPress

After creating a WordPress plugin, I am considering revamping its layout with the help of bootstrap CSS and js. However, I have encountered issues in the past due to conflicting CSS naming conventions. I want to ensure that there are no namespace conflicts ...

Struggling to decide on the perfect CSS selector for my puppeteer script

I am trying to use puppeteer page.type with a CSS selector. <div class="preloader"> <div class="cssload-speeding-wheel"></div> </div> <section id="wrapper" class="login-register"> <div class="login-box"> <d ...

Create a Bootstrap grid that perfectly fits the viewport without any overflowing content

I'm currently utilizing Bootstrap 5 in an attempt to design a simplistic layout consisting of an MxN grid of cells, each of equal size. My goal is to have this grid fill the entire viewport without any scrollbars appearing in either direction. However ...

The button is not being vertically centered when using the boostrap pull-right class

---------------------------------------------------------------- | Title | | Button | --> (using .pull-right) the button is not aligned vertically ------------------------------------------------------------- ...