I successfully modified the technique found at https://dev.to/kallmanation/styling-a-radio-button-with-only-css-4llc to achieve the desired outcome. (The checkboxes now display a solid fill color instead of checkmarks when selected.)
Check out the code snippet below:
library(shiny)
ui <- fluidPage(
tags$head(
tags$style(HTML("
label > input[type='radio'] {
opacity: 0;
position: absolute;
}
label > input[type='radio'] + *::before {
content: '';
margin: 4px 0 0;
width: 13px;
height: 13px;
position: absolute;
margin-left: -20px;
border-radius: 50%;
border-style: solid;
border-width: 0.1rem;
border-color: #007d3c;
}
label > input[type='radio']:checked + *::before {
background: radial-gradient(white 0%, white 30%, #007d3c 30%, #007d3c);
border-color: #007d3c;
}
label > input[type='checkbox'] {
opacity: 0;
position: absolute;
}
label > input[type='checkbox'] + *::before {
content: '';
position: absolute;
margin: 4px 0 0;
margin-left: -20px;
align: center;
width: 13px;
height: 13px;
margin-right: 1rem;
border-radius: 0%;
border-style: solid;
border-width: 0.1rem;
border-color: #007d3c;
}
label > input[type='checkbox']:checked + *::before {
content: '';
width: 13px;
height: 13px;
background-color: #007d3c;
}
"))
),
checkboxGroupInput(inputId = "maDays", label = "Select Trading Days",
choices = c("Monday", "Tuesday", "Wednesday", "Thursday",
&qout;Friday", &qout;Saturday", &qout;Sunday"),
selected = c("Monday", "Tuesday", "Wednesday", "Thursday",
"Friday"),
inline = TRUE),
radioButtons(inputId = "matimegran", label = "Select Time Granularity",
choices = c("hourly" = "hour", "daily" = "day",
"weekly" = "week"),
selected = "day")
)
server <- function(input, output) {
## put server code here
}
shinyapp(ui = ui, server = server)
And below is my original response, which alters the style of labels for checked elements in case others find it helpful:
library(shiny)
ui <- fluidpage(
tags$head(
tags$style(HTML("
input:checked + span {
color: #007d3c;
}
"))
),
checkboxgroupinput(inputid = "madays", label = "select trading days",
choices = c("monday", "tuesday", "wednesday", "thursday",
"friday", "saturday", "sunday"),
selected = c("monday", "tuesday", "wednesday", "thursday",
"friday"),
inline = true),
radiobuttons(inputid = "matimegran", label = "select time granularity",
choices = c("hourly" = "hour", "daily" = "day",
"weekly" = "week"),
selected = "day")
)
server <- function(input, output) {
## put server code here
}
shinyapp(ui = ui, server = server)