Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ColinFay/handydandy
Easy CSS Styling for Shiny
https://github.com/ColinFay/handydandy
Last synced: 9 days ago
JSON representation
Easy CSS Styling for Shiny
- Host: GitHub
- URL: https://github.com/ColinFay/handydandy
- Owner: ColinFay
- License: other
- Created: 2018-06-03T20:31:17.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-06-04T05:06:17.000Z (over 6 years ago)
- Last Synced: 2024-08-13T07:15:35.584Z (4 months ago)
- Language: R
- Size: 50.8 KB
- Stars: 22
- Watchers: 4
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - ColinFay/handydandy - Easy CSS Styling for Shiny (R)
README
---
output: github_document
---```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```[![lifecycle](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)
# handydandy
The goal of {handydandy} is to provide an easy to use API for bringing style to a shiny app with CSS.
## Installation
You can install the dev version of {handydandy} with:
``` r
remotes::install_github("ColinFay/handydandy")
```## Example
### Add, update, remove css elements
```{r example}
library(handydandy)# Create a new dandy
css <- Dandy$new()# It's easy to add a new style, you need to pass
# + a selector
# + a list of property = valuecss$add_style("body", list("font-family" = "Helvetica",
"color" = "#24292e"))
css$add_style("h2", list("font-size" = "3 em",
"color" = "#911414",
"text-align" = "center"))
css# Easy to update
css$update_style("body","color","#911414")
css# Or to remove one
css$remove_style("body")
css# You can also simply remove one part of your tag
css$remove_style("h2", "color")
css
```### In a shiny app
The idea of course is to use it in shiny app:
```{r eval = FALSE}
css <- Dandy$new()css$add_style("body", list("font-family" = "Helvetica",
"color" = "#24292e"))
css$add_style("h2", list("color" = "#911414",
"text-align" = "center"))
css$add_style("h3", list("color" = "#2E2E8F",
"text-align" = "center"))ui <- fluidPage(
# Give swag to your app
css$swag(),
textInput("lol","lol", "lol"),
textOutput("lolilol"),
h2("lol"),
h3("pouet")
)server <- function(input, output, session) {
output$lolilol <- renderText({
input$lol
})
}shinyApp(ui, server)
```![](readme-fig/handydandy.png)