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

139
Visualizações
Creating a React CSS object with clamp and focus

I'm trying to create an object to use it in inline style but I don't know how to how to write clamp and after the right way.

const PhoneInputStyle = {
    fontSize: clamp("13px", "1.111vw", "16px"),   /*this is giving me trouble
    lineHeight: clamp("15px", "1.319vw", "19px"), */
    position: "relative",
    width: "100%",
    height: "51px",
    cursor: "pointer",
    display: "flex",
    flexDirection: "row",
    alignItems: "center",
    padding: "8px 16px",
    border: "1px solid ${COLOR_NOT_BLACK}",
    boxSizing: "border-box",
    borderRadius: "10px",
    outline: "none",
    &:focus {                                           /*this is giving me trouble
        border: "1px solid ${COLOR_SALMON} !important",
    }                                                   */
    gridRowStart: "1",
    gridColumnStart: "1"
}

The error I get on clamp is : Cannot find name 'clamp'

What I get on focus is : Expression expected (on the &)

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You need to make the whole thing a string e.g. {fontSize: "clamp(13px, 1.111vw, 16px)"}

For the focus, I think you'll need something like: https://styled-components.com/

-edit-

Perhaps you could create a wrapper component that you can set an onHover event handler on.

Something along the lines of...

<div
  style={isShown ? {border: "1px solid ${COLOR_SALMON}"}: ""}
  onMouseEnter={() => setIsShown(true)} 
  onMouseLeave={() => setIsShown(false)}
>
  {children}
</div>

This would probably even work without needing to set a wrapper 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