All Projects → stla → shinyChakraUI

stla / shinyChakraUI

Licence: GPL-3.0 License
A wrapper of the React library 'Chakra UI' for usage in Shiny.

Programming Languages

javascript
184084 projects - #8 most used programming language
r
7636 projects
CSS
56736 projects

Projects that are alternatives of or similar to shinyChakraUI

QualtricsTools
Using R, Shiny, Pandoc, JSON, CSVs and more to automate processing Qualtrics surveys
Stars: ✭ 14 (-17.65%)
Mutual labels:  shiny
parcours-r
Valise pédagogique pour la formation à R
Stars: ✭ 25 (+47.06%)
Mutual labels:  shiny
bfast-explorer
Breakpoint detection of Landsat pixel time series via BFAST-based algorithms, provided as a Shiny app
Stars: ✭ 17 (+0%)
Mutual labels:  shiny
d3Tree
htmlwidget that binds d3js collapsible trees to R and Shiny to make an interactive search tool
Stars: ✭ 79 (+364.71%)
Mutual labels:  shiny
dog days
Using AWS RDS and S3 to store data about my dogs' vaccination and medical records. Creating an R shiny app to keep track of and share records with vets. 🐶 🐶
Stars: ✭ 44 (+158.82%)
Mutual labels:  shiny
learning R
List of resources for learning R
Stars: ✭ 32 (+88.24%)
Mutual labels:  shiny
GAlogger
Log R Events and R Usage to Google Analytics
Stars: ✭ 23 (+35.29%)
Mutual labels:  shiny
waypointer
Waypoints & Animations for Shiny
Stars: ✭ 16 (-5.88%)
Mutual labels:  shiny
datamods
Shiny modules to import data into an application or addin
Stars: ✭ 80 (+370.59%)
Mutual labels:  shiny
pdfcount
An R Shiny App to Count Words in a PDF Document
Stars: ✭ 26 (+52.94%)
Mutual labels:  shiny
memory-hex
Hex Memory Game in Shiny
Stars: ✭ 29 (+70.59%)
Mutual labels:  shiny
machLearn
Machine learning dashboard created with R/shiny
Stars: ✭ 74 (+335.29%)
Mutual labels:  shiny
flexpivot
Simple frequency table
Stars: ✭ 19 (+11.76%)
Mutual labels:  shiny
eAnalytics
Dynamic Web-based Analytics for the Energy Industry
Stars: ✭ 28 (+64.71%)
Mutual labels:  shiny
topicApp
A simple Shiny App for Topic Modeling in R
Stars: ✭ 40 (+135.29%)
Mutual labels:  shiny
vov
✨ vov.css animations for shiny
Stars: ✭ 23 (+35.29%)
Mutual labels:  shiny
rfrappe
htmlwidget for frappe charts js library
Stars: ✭ 24 (+41.18%)
Mutual labels:  shiny
pirate
🏴‍☠️ A personal platform for R programming
Stars: ✭ 36 (+111.76%)
Mutual labels:  shiny
workshops-setup cloud analytics machine
Tips and Tricks to setup a cloud machine for Analytics and Data Science with R, RStudio and Shiny Servers, Python and JupyterLab
Stars: ✭ 12 (-29.41%)
Mutual labels:  shiny
PowerAnalysisIL
Shiny app and R package to perform a power analysis to select the number of participants in intensive longitudinal studies
Stars: ✭ 19 (+11.76%)
Mutual labels:  shiny

shinyChakraUI

library(shiny)
library(shinyChakraUI)

The shinyChakraUI package is a wrapper of the React library Chakra UI. A very good documentation of this library is available at https://chakra-ui.com/.

Basics

  • Use chakraPage to define your Shiny UI.

  • Use chakraComponent to define a Chakra component.

For example, here is a Chakra alert component:

React states

You can use React states with the help of the withStates function. Here is an example:

The states are defined in the second argument of the withStates function, in a list. Here one state is defined: heading = "I am the heading.". The state is obtained in the Chakra component with the help of the R function getState. To change the value of a state, you have to resort to JavaScript. The JavaScript code must be given as a character string in the R function jseval. Here it is given in the onClick attribute of the Chakra button: jseval("() => setState('heading', 'New heading!')"). When the button is clicked, the 'heading' state takes the new value 'New heading!'.

Writing JSX code

So far, we built React components with the help of the Tag constructor. It is also possible to build a React component by writing its JSX code, with the help of the jsx function. Here is an example:

The jsx function takes two arguments. The first one is the JSX element and the second one, named preamble, is some JavaScript code to be executed at first.

Setting a React state from Shiny server

In the 'heading' React state example, we set the new value of the state with the help of the JavaScript function setState, executed from the R function jseval. It is also possible to set a React state from the Shiny server function, with the setReactState function. It offers more possibilities: it allows to set as a new value a React component, a JSX element, a Shiny widget, or some HTML code. Here is an example:

More examples

Run chakraExamples() to get the list of available examples provided in the package. See also the examples of the built-in widgets chakraAlertDialog, chakraCheckboxWithChildren, chakraDrawer, chakraSlider, chakraCombinedSlider, and chakraModal.

The ‘JSX parser’ RStudio addin

The package provides a RStudio addin which allows to convert some JSX code to the corresponding R code to use in the chakraComponent function. For example, consider this JSX code:

<CheckboxGroup colorScheme="green" defaultValue={["naruto", "kakashi"]}>
  <HStack>
    <Checkbox value="naruto">Naruto</Checkbox>
    <Checkbox value="sasuke">Sasuke</Checkbox>
    <Checkbox value="kakashi">kakashi</Checkbox>
  </HStack>
</CheckboxGroup>

Copy it to your clipboard, and then select the ‘JSX parser’ addin in the RStudio Addins menu. You’ll get this R code:

Tag$CheckboxGroup(
  colorScheme = "green", defaultValue = list("naruto", "kakashi"),
  Tag$HStack(
    Tag$Checkbox(value = "naruto", "Naruto"),
    Tag$Checkbox(value = "sasuke", "Sasuke"),
    Tag$Checkbox(value = "kakashi", "kakashi")
  )
)

This JSX parser is not perfect. It may fail, or you may have to manually modify the output.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].