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

272
Visualizações
Next.js Image Styling through css

I have a next JS component here:

import styles from '../styles/Navbar.module.css'
import Image from 'next/image'

export const Navbar = () => {
    <div>
        <Image className={styles["navbar-home-icon"]} src="/vercel.svg"/>
    </div>
}

Navbar.module.css:

.navbar-home-icon {
    width: 60px;
    height: 60px;
    border: 5px solid red;
}

The problem is, I can't use the navbar-home-icon class to set the width and height of the image. Not even the border shows up. It throws this error

Error: Image with src "/vercel.svg" must use "width" and "height" properties o r "layout='fill'" property

I know the css file is being detected because this is what shows up in the developer view:enter image description here

If I add in height and width properties into the tag itself, the image shows up.

I understand what the error is, but how do I control the width/height/any other property through my css file? - Instead of explicitly declaring them inside the Image tag?

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

0

Put Image inside div and put the following props on the Image:

<div className="div-class">
   <Image src=“/vercel.svg” layout="fill" objectFit="cover" />
</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