Created
October 10, 2025 15:51
-
-
Save bastianolea/1c46fa94b71f167b927bc0a4a7399b41 to your computer and use it in GitHub Desktop.
App Shiny con tema de colores personalizado, que muestra emojis de animales de tamaño variable
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
| library(shiny) | |
| library(bslib) | |
| ui <- page_fluid( | |
| theme = bs_theme(bg = "#EAD1FA", | |
| fg = "#553A74", | |
| primary = "#8557AB"), | |
| br(), | |
| h1("App Shiny ✨"), | |
| # selector de opciones | |
| selectInput("animal", label = "Animalito", | |
| choices = c("Gatito", "Gallineta", "Ratita")), | |
| # deslizador de tamaño | |
| sliderInput("tamaño", label = "Tamaño", | |
| min = 16, max = 128, value = 48, ticks = FALSE), | |
| htmlOutput("animales") | |
| ) | |
| server <- function(input, output, session) { | |
| # generar animalito con texto y emoji | |
| output$animales <- renderUI({ | |
| # animal y texto según selección | |
| if (input$animal == "Gatito") { | |
| animal <- list("texto" = "Miu", | |
| "emoji" = "🐈") | |
| } else if (input$animal == "Gallineta") { | |
| animal <- list("texto" = "Cocorocó", | |
| "emoji" = "🐓") | |
| } else if (input$animal == "Ratita") { | |
| animal <- list("texto" = "Mimimi", | |
| "emoji" = "🐁") | |
| } | |
| # generar interfaz para mostrar el animalito | |
| div( | |
| # título del animal | |
| h3(em(animal$texto)), | |
| # emoji del animal | |
| div(animal$emoji, | |
| # tamaño del animalito | |
| style = css(font_size = paste0(input$tamaño, "px")) | |
| ) | |
| ) | |
| }) | |
| } | |
| shinyApp(ui, server) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment