Package 'fivestars'

Title: Generates HTML/CSS star ratings
Description: Creates HTML and CSS star ratings in web documents.
Authors: Tan Ho [aut, cre]
Maintainer: Tan Ho <[email protected]>
License: MIT + file LICENSE
Version: 0.0.1
Built: 2024-10-30 04:00:21 UTC
Source: https://github.com/tanho63/fivestars

Help Index


Add a star

Description

This function creates an HTML tag with the appropriate number of stars, as well as an accessibility label.

Usage

fivestars(
  rating,
  label = round(rating, 1),
  aria_label = paste("The rating is", round(rating, 1), "out of five stars"),
  label_pos = "left",
  star_size = NULL,
  star_color = NULL,
  star_background = NULL
)

Arguments

rating

rating out of five

label

text to display in tag, defaults to the rating rounded to one decimal place

aria_label

accessibility label for text

label_pos

"left" or "right" - position of label relative to stars

star_size

CSS font-size for star background, default is to inherit from use_fivestars()

star_color

CSS colour for stars, default is to inherit from use_fivestars()

star_background

CSS colour for star background, default is to inherit from use_fivestars()

Value

an html tag that renders a star rating out of five

Examples

use_fivestars()
fivestars(3.5)

Add stars CSS

Description

This function adds the appropriate CSS to your page for star ratings.

Usage

use_fivestars(
  star_size = "larger",
  star_color = "#fc0",
  star_background = "#999"
)

Arguments

star_size

CSS font size for your stars, default is "larger"

star_color

CSS colour for star, default is ⁠#fc0⁠

star_background

CSS colour for star background, default is ⁠#999⁠

Value

HTML that inserts CSS into the page head

Examples

use_fivestars()