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.io: Get the most out of your content

Sanity.io is a platform to build websites and applications. It comes with great APIs that let you treat content like data. Give your team exactly what they need to edit and publish their content with the customizable Sanity Studio. Get real-time collaboration out of the box. Sanity.io comes with a hosted datastore for JSON documents, query languages like GROQ and GraphQL, CDNs, on-demand asset transformations, presentation agnostic rich text, plugins, and much more.

Don't compromise on developer experience. Join thousands of developers and trusted companies and power your content with Sanity.io. Free to get started, pay-as-you-go on all plans.