is_color_hex: Check if an argument is a hex color string

View source: R/string.R

is_color_hexR Documentation

Check if an argument is a hex color string

Description

Validates hex color codes in ⁠#RGB⁠, ⁠#RGBA⁠, ⁠#RRGGBB⁠, or ⁠#RRGGBBAA⁠ format.

Usage

is_color_hex(x)

Arguments

x

(any)
Object to check.

Value

TRUE if x is a valid hex color string, FALSE otherwise.

References

https://www.w3.org/TR/css-color-4/#hex-notation

Examples

is_color_hex("#FF5733")
is_color_hex("#fff")

checkstring documentation built on Sept. 28, 2026, 5:07 p.m.