text_active: Function to create 'active text'

View source: R/text_active.R

text_activeR Documentation

Function to create 'active text'

Description

Active text takes a string, inserts numbers and/or words at pre-defined points in the string, and styles the inserted numbers/words with CSS. Active text is intended for use in Shiny apps.

Usage

text_active(string, numbers, colour = "#ffffff", alpha = 25, extra_style = "")

Arguments

string

A length-one character vector, with XX inserted at points where you want the elements of numbers to be inserted

numbers

A vector (numeric or character) of numbers and/or words you want to insert at the points marked XX in string.

colour

Background colour for the inserted text (numbers)

alpha

Alpha (transparency) for the inserted text (numbers), where 100 is no transparency, 0 is full transparency.

extra_style

Additional CSS to style the inserted text, such as "font-weight: bold;".

Value

Length-one character vector, with inline CSS.

Examples

string <- "The unemployment  rate went up by XX percentage points to XX per cent."
numbers <- c(0.2, 6.1)
text_active(string, numbers)
text_active(string, numbers, colour = "#007b4b", alpha = 0.5)
text_active(string, numbers,
  colour = "#007b4b", alpha = 0.5,
  extra_style = "font-weight: bold;"
)

djpr-data/djprshiny documentation built on May 14, 2023, 1:15 p.m.