👀 Our most exciting product launch yet 🚀 Join us May 8th for Sanity Connect

How to render code blocks with SanityContent components and style them properly.

2 replies
Last updated: Apr 15, 2024
Hey team, I’ve been scouring the internet for this without much luck – does anyone know how to render code blocks with SanityContent components? I added code blocks to my richtext input, but they’re getting rendered as plain paragraphs without any distinguishing characteristics, making it impossible to style them.
Apr 15, 2024, 2:46 PM
Is this on your frontend or in the Studio?
Apr 15, 2024, 5:08 PM
Both, though I’ve now figured this one out. Had to add some additional options to the code-input blok aaand set up serializers with a custom component.
Apr 15, 2024, 7:50 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?