# Parse OKLCH CSS string to hex
from_css("oklch(62.792% 0.258 29.221 / 1)")
# Parse RGB CSS string (modern & legacy)
from_css("rgb(255 0 0 / 1)", to = "oklch")
from_css("rgb(255, 0, 0)", to = "hex")
# Parse HSL CSS string
from_css("hsl(210 50% 40% / 1)", to = "rgb")
# Also works with hex colors
from_css("#ff0000", to = "oklch")
# Vectorized
from_css(c("oklch(62.792% 0.258 29.221 / 1)", "rgb(0 255 0 / 1)"))
Run the code above in your browser using DataLab