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

96
Visualizações
Creating styled-component for component but don't know type

I'm using the styled-components library, and am trying to style a component, but I don't know the type. I've tried a bunch but I keep getting an error Error: Cannot create styled-component for component. Thanks in advance for any help!

export const StyledSupply = styled.text `
  textAlign: "center",
  fontSize: 30,
  fontWeight: "bold",
  color: "var(--accent-text)"
`;

<s.TextTitle style={StyledSupply}>
    {data.totalSupply} / {CONFIG.MAX_SUPPLY}
</s.TextTitle>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I suggest you look at examples from the documentation: https://styled-components.com/docs/basics#getting-started

If you just want to style some text, you could try changing your code to something like this:

// Styled Component
export const StyledSupply = styled.span`
  textAlign: center;
  fontSize: 30;
  fontWeight: bold;
  color: var(--accent-text);
`;

// Render
<StyledSupply>
    {data.totalSupply} / {CONFIG.MAX_SUPPLY}
</StyledSupply>

You might need to define --accent-text as a variable and use it instead.

Additionally, your CSS properties may need to be use the official names, e.g. textAlign might need to be text-align, etc.

You can this a step further if s.TextTitle is a valid component and accepts className as a prop, you can do this:

// Styled Component
export const StyledTextTitle = styled(s.TextTitle)`
  text-align: center;
  font-size: 30;
  font-weight: bold;
  color: var(--accent-text);
`;

// Render
<StyledTextTitle>
    {data.totalSupply} / {CONFIG.MAX_SUPPLY}
</StyledTextTitle>

Docs: https://styled-components.com/docs/basics#styling-any-component

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