Last active
October 4, 2025 14:35
-
-
Save berkorbay/2ff837f8762f9d256573c19b91937216 to your computer and use it in GitHub Desktop.
Changing the min/max labels in Shiny sliders
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ui <- fluidPage( | |
| tags$head( | |
| #Using ionRangeSlider's javascript options you can hide/show selector labels and min/max labels | |
| HTML(" | |
| <script> | |
| $(document).ready(function(){ | |
| $(\".js-range-slider\").ionRangeSlider({ | |
| hide_min_max: false, | |
| hide_from_to: true | |
| }); | |
| }); | |
| </script> | |
| ") | |
| ), | |
| #This CSS hack first hides the text within the span tags of the specified classes | |
| #Then it adds desired text and CSS properties. !important parameter is to override | |
| #inline css parameters. | |
| tags$style(type = "text/css", " | |
| .irs-min {visibility:hidden !important;} | |
| .irs-max {visibility:hidden !important;} | |
| .js-irs-0 .irs .irs-min:after {content:'Hello' !important;} | |
| .js-irs-0 .irs .irs-max:after {content:'Shiny' !important;} | |
| //Restore css defaults to .irs-min and .irs-max | |
| .irs-min:after { | |
| visibility: visible !important; | |
| display: block; | |
| background: rgba(0, 0, 0, 0.1) none repeat scroll 0 0; | |
| border-radius: 3px; | |
| color: #333; | |
| font-size: 10px; | |
| line-height: 1.333; | |
| padding: 1px 3px; | |
| text-shadow: none; | |
| top: 0; | |
| cursor: default; | |
| display: block; | |
| left: 0; | |
| position: absolute;} | |
| .irs-max:after { | |
| visibility: visible !important; | |
| display: block; | |
| background: rgba(0, 0, 0, 0.1) none repeat scroll 0 0; | |
| border-radius: 3px; | |
| color: #333; | |
| font-size: 10px; | |
| line-height: 1.333; | |
| padding: 1px 3px; | |
| text-shadow: none; | |
| top: 0; | |
| cursor: default; | |
| display: block; | |
| right: 0; | |
| position: absolute;} | |
| "), | |
| sliderInput(inputId="test", label=NULL, min=1, max=10, value=5, step = 1, width='100%') | |
| ) | |
| server <- function(input, output, session){ | |
| } | |
| shinyApp(ui = ui, server=server) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Has anyone been able to solve this problem