Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

how to parse the data from the sanity color picker plugin?

3 replies
Last updated: Oct 3, 2020
has any one got any ideas on how to parse the data from the sanity color picker plugin? It seems to come in a format that HTML does not like.
Oct 3, 2020, 5:02 PM
I tried something like this, but the formats don’t match
Oct 3, 2020, 5:06 PM
RGBA values worked fine 🙂
Oct 3, 2020, 5:22 PM
For those interested, here is my final implementation
//Color picker
const colorPicker = (props) => {
  const rgbaValues = `rgba(${props.color.rgb.r}, ${props.color.rgb.g}, ${props.color.rgb.b}, ${props.color.rgb.a} )`;
  return rgbaValues;
};
export default colorPicker;
In use

  const ColorTest = styled.p`
    color: ${colorPicker(props)};
  `;
Oct 3, 2020, 5:29 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?