Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tanho63/fivestars

⭐⭐⭐⭐⭐ Generates HTML/CSS star ratings
https://github.com/tanho63/fivestars

Last synced: 3 months ago
JSON representation

⭐⭐⭐⭐⭐ Generates HTML/CSS star ratings

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# fivestars ⭐⭐⭐⭐⭐

[![Dev status](https://img.shields.io/github/r-package/v/tanho63/fivestars/main?label=dev%20version&style=flat-square&logo=github)](https://fivestars.dynastyprocess.com/)
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg?style=flat-square)](https://lifecycle.r-lib.org/articles/stages.html)

The goal of {fivestars} is to generate star ratings with HTML and CSS.

## Installation

Install the development version from GitHub with:

```{r eval = FALSE}
install.packages("fivestars", repos = "https://tanho63.r-universe.dev")

# or use remotes/devtools
# install.packages("remotes")
remotes::install_github("tanho63/fivestars")
```

## Usage

```{r}
library(fivestars)
```

`use_fivestars()` adds the appropriate CSS and allows for some configuration of defaults (star size, colour, and background).

```{r}
use_fivestars(
star_size = "20px", # default is "larger"
star_color = "#fc0", # default
star_background = "#999" # default
)
```

Minimal usage of the `fivestar` function looks like this:

```{r}
fivestars(rating = 3.5)
```



The output can be further customized with some arguments, e.g.
```{r}
fivestars(rating = 1.2,
label = "Poor",
label_pos = "right",
aria_label = "This item is rated 'Poor'",
star_color = "#d13",
star_background = "#000")
```