Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

142
Vistas
styled(Component) does not apply styles on functional component

1. I have a component that is written with styled-components

2. Calling that component inside of new Styled component

3. Attach styles

Result: Styles are not applied

export const WarningBox = styled(InfoBox)`
${({ theme }) => css`
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  font-size: 12px;
  padding: 16px;
  border-radius: 4px;
  background-color: ${theme.colors.yellow[150]};
  border: 1px solid ${theme.colors.yellow[700]};

  a {
    font-family: Montserrat;
    font-weight: 500;
    color: ${theme.colors.blue[900]};
    margin-right: 15px;
  }
`}}
`;

This is InfoBox that I want to customize:

const Container = styled.div`
${({ theme }) => css`
  padding: 16px;
  width: 100%;
  min-height: 110px;
  border-radius: 4px;
  background-color: ${theme.colors.green[150]};
`}}
`;

...rest of the styled-components...

type InfoBoxProps = {
  title?: string;
  text?: string;
  icon?: React.ReactNode;
};

export const InfoBox: FC<InfoBoxProps> = ({
  title = '',
  text = '',
  icon,
  children,
}) => (
  <Container className="box-container">
    <Text>{text}</Text>
    {children}
  </Container>
);
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You need to pass the className prop of InfoBox to its container, otherwise is not going to apply the styles:

type InfoBoxProps = {
  className?: string;
  title?: string;
  text?: string;
  icon?: React.ReactNode;
};

export const InfoBox: FC<InfoBoxProps> = ({
  className,
  title = '',
  text = '',
  icon,
  children,
}) => (
  <Container className={`box-container ${className}`}>
    <Text>{text}</Text>
    {children}
  </Container>
);
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda