Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

245
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda