combine_ansi_styles

0th

Percentile

Combine two or more ANSI styles

Combine two or more styles or style functions into a new style function that can be called on strings to style them.

Usage
combine_ansi_styles(...)
Arguments
...

The styles to combine. For character strings, the make_ansi_style() function is used to create a style first. They will be applied from right to left.

Details

It does not usually make sense to combine two foreground colors (or two background colors), because only the first one applied will be used.

It does make sense to combine different kind of styles, e.g. background color, foreground color, bold font.

Value

The combined style function.

See Also

Other ANSI styling: ansi-styles, make_ansi_style()

Aliases
  • combine_ansi_styles
Examples
# NOT RUN {
## Use style names
alert <- combine_ansi_styles("bold", "red4")
cat(alert("Warning!"), "\n")

## Or style functions
alert <- combine_ansi_styles(style_bold, col_red, bg_cyan)
cat(alert("Warning!"), "\n")

## Combine a composite style
alert <- combine_ansi_styles(
  "bold",
  combine_ansi_styles("red", bg_cyan))
cat(alert("Warning!"), "\n")
# }
Documentation reproduced from package cli, version 2.0.1, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.