Finding an intuitive solution for line breaks in PortableText.

5 replies
Last updated: Feb 18, 2024
Hi there! Why line breaks have to be that much of a pain in PortableText? Did you guys found any intuitive solution so you get an empty line on each press of the Enter key?
Jan 30, 2024, 10:21 AM
Do you mean the output of the PortableText? You can use the
white-space: pre-line;
on the element, then linebreaks are treated as br/
Jan 30, 2024, 3:31 PM
For now im using Shift+Enter for line breaks but i will try
pre-line
as soon as i find some time. Thanks!
Feb 1, 2024, 9:11 PM
Hello
user G
I added
white-space: pre-line
on my rich text components like this:
Feb 18, 2024, 12:15 PM
but the text editor treats line breaks as
<p>
tags:
Feb 18, 2024, 12:16 PM
how can i stop this behaviour?
Feb 18, 2024, 12:16 PM

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?