Back to skills
SKILL.md
Shinyjs
ASecurityR shinyjs package for JavaScript operations. Use for show/hide, enable/disable, and custom JS in Shiny.
- 5 stars
- 0 votes
- 0 copies
- 0 views
- Added June 5, 2026
Security analysis
100/100npx -y skills add LeoLin990405/r-analytics-skill --skill shinyjs --agent claude-codeAre you the author of Shinyjs?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/leolin990405-shinyjs)---
name: shinyjs
description: R shinyjs package for JavaScript operations. Use for show/hide, enable/disable, and custom JS in Shiny.
---
# shinyjs Package
JavaScript operations in Shiny without writing JS.
## Setup
```r
library(shiny)
library(shinyjs)
ui <- fluidPage(
useShinyjs(), # Required!
# ... rest of UI
)
```
## Show/Hide
```r
# UI
div(id = "myDiv", "Content to show/hide")
actionButton("toggle", "Toggle")
# Server
observeEvent(input$toggle, {
toggle("myDiv")
})
# Other options
show("myDiv")
hide("myDiv")
toggle("myDiv", anim = TRUE, animType = "fade")
```
## Enable/Disable
```r
# UI
textInput("text", "Input"),
actionButton("btn", "Submit")
# Server
observe({
if (nchar(input$text) > 0) {
enable("btn")
} else {
disable("btn")
}
})
# Toggle
toggleState("btn", condition = nchar(input$text) > 0)
```
## CSS Classes
```r
addClass("myDiv", "highlight")
removeClass("myDiv", "highlight")
toggleClass("myDiv", "highlight")
```
## HTML Content
```r
html("myDiv", "New content")
html("myDiv", "<b>Bold</b>", add = TRUE)
```
## Reset
```r
# Reset input to default
reset("text")
reset("form") # Reset all inputs in container
```
## Run JavaScript
```r
# Run custom JS
runjs("alert('Hello!')")
runjs("$('#myDiv').css('color', 'red')")
# Extended functions
extendShinyjs(text = "shinyjs.hello = function() { alert('Hi!'); }")
# Then call: js$hello()
```
## Delay
```r
delay(1000, show("myDiv")) # Show after 1 second
```
Attribution
Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.