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

344
Visualizações
how to type component using css emotion?

I have this component and I can't use the theme with typescript

const buttonDisabled = css`
  color: ${({ theme }) => theme.color};
`;

How can I type this component?

error:  No overload matches this call.
  Overload 1 of 2, '(template: TemplateStringsArray, ...args: CSSInterpolation[]): SerializedStyles', gave the following error.
    Argument of type '({ theme }: { theme: any; }) => any' is not assignable to parameter of type 'CSSInterpolation'.
      Type '({ theme }: { theme: any; }) => any' is missing the following properties from type 'CSSInterpolation[]': pop, push, concat, join, and 28 more.
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Take help from their official documentation it have everything related to create a component in emotion https://emotion.sh/docs/styled and Simplest way to create a component using emotion css is

import styled from '@emotion/styled'

const Button = styled.button`
  color: turquoise;
`

render(<Button>This my button component.</Button>)

pass props

import "./styles.css";
import styled from "@emotion/styled";

export const DIV = styled.div`
  background-color: pink;
  color: ${(props) => props.color};
`;

export default function App() {
  return (
    <div className="App">
      <h1>Hello CodeSandbox</h1>
      <h2>Start editing to see some magic happen!</h2>
      <DIV color="blue">Hello World</DIV>
    </div>
  );
}

and if u want to only use css

import "./styles.css";
import {css} from '@emotion/css';

const color = 'blue';

export const buttonDisabled = css`
  color:${color}
`;

export default function App() {
  return (
    <div className="App">
      <h1>Hello CodeSandbox</h1>
      <h2>Start editing to see some magic happen!</h2>
      <div className={buttonDisabled}>Hello World</div>
    </div>
  );
}

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