Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

244
Views
Text disappears if adding styles to markdown text + Can't add background color to markdown text

I'm having this very odd issue with React markdown.

Inside of this code:

<ReactMarkdown
    className={styles.reactMarkDown}
    escapeHtml={false}
    components={renderers}
>

    {content}

</ReactMarkdown>

I am trying to add a background color to the markdown text (content). Inside of styles.reactMarkDown, there is background-color: #some-color. Unfortunately, the background color doesn't get added. I've verified that the CSS rule is actually loading because the custom font in there is loading.

I tried to get around this using a <span> element:

<ReactMarkdown
    className={styles.reactMarkDown}
    escapeHtml={false}
    components={renderers}
>

    <span className="bg-postbg text-white">{content}</span>

</ReactMarkdown>

But then the text disappears. I've tried searching for a while, and nothing comes close to it. What am I doing wrong?

Here's an image of what's going on:

A background is not being applied.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You should wrap the ReactMarkdown with a div and apply the style to it.

<div  >
    <ReactMarkdown
       // apply background property inside this className
       className={styles.reactMarkDown}
       escapeHtml={false}
       components={renderers}
    >
       {content}
   </ReactMarkdown>
</div>
about 4 years ago · Juan Pablo Isaza Report

0

Turns out I was an idiot and didn't use my renderers correctly. For anyone else stumbling upon this post, add

const renderers = {
    p: (props) => <p className={styles.reactMarkDown}>{props.children}</p>
}

or whatever stylesheet you're using. I accidentally named it paragraph.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!