Learn R Programming

gghdx (version 0.2.0)

hdx_colors: Hex values for HDX colors

Description

hdx_colors() conveniently returns a vector of hex values for specified color ramps. Full values can be found in hdx_color_list. If you know the name of the color you want, such as "sapphire-hdx", you can use hdx_hex(c("sapphire-hdx")) to directly access the hex code.

Usage

hdx_colors(colors = c("sapphire", "mint", "tomato", "gray"))

hdx_colours(colors = c("sapphire", "mint", "tomato", "gray"))

hdx_hex(color_names)

hdx_color_names()

hdx_colour_names()

Value

  • hdx_colors() returns a named vector of hex values.

  • hdx_color_names() returns a character vector of color names.

Arguments

colors

Specified color ramps to return. Some set of "sapphire", "mint", "tomato", "gray", "primary", "brand", "neutral", "success", "warning", and "error". By default returns the original "sapphire", "mint", "tomato", and "gray" colors.

color_names

Vector of color names. Valid values are all available using hdx_colors

Details

All valid color names are in the named vector returned by hdx_colors() or accessible in the convenient hdx_color_names().

As of the 2025 HDX website redesign, the "primary", "brand", "neutral", "success", "warning", and "error" scales are also available, following the step naming of the HDX design tokens (e.g. "primary-5" for the primary scale's base blue, "neutral-2" for a hairline gridline gray). These are not returned by default to avoid breaking existing uses of hdx_colors(); request them explicitly, e.g. hdx_colors("primary"). The original "sapphire", "mint", and "tomato" scales are kept for backwards compatibility but are superseded by "primary"/"brand"/"error" going forward.

See Also

Other color hdx: hdx_color_list, hdx_pal_discrete()

Examples

Run this code
# get hex values
hdx_colors()
hdx_colors("sapphire")

# 2025 redesign colors
hdx_colors("primary")

# get color names
hdx_color_names()

Run the code above in your browser using DataLab