Next.js Discord

Discord Forum

How can I stop next/link from changing css styles?

Answered
!=tgt posted this in #help-forum
Open in Discord
Avatar
I'm using next/link on a glui card component and whenever I use it as a parent of the Card component, it messes up css styles.
Here's the code below:
        {Object.keys(images).map((image) => {
          const { friendlyName, description, icon } = images[image];
          return (
            <Link href="https://google.com" className="" passHref key={image}>
            <Card
              key={image}
              className="flex gap-2 justify-between w-96 h-36 bg-bg-darker"
            >
              <Image src={icon} alt={friendlyName} width={96} height={96} />
              <div className="flex flex-col justify-center">
                <p className="text-text-primary font-bold text-lg">{friendlyName}</p>
              <p className="text-text-secondary font-medium">{description}</p>
              </div>
            </Card>
            </Link>

          );
        })}
Answered by !=tgt
Ok I managed to fix the issue by changing the nesting
View full answer

11 Replies

Avatar
You're going to have to override all the default styles that come with a tags
I'm guessing you've got blue text
and an underline
you can set text-decoration: none and color: black !important
Look here if you want to see all the defauly styles for a tags. https://www.w3schools.com/cssref/css_default_values.php
Image
Avatar
Nope
I'm nesting a card component
inside
Avatar
What weird styles are you getting
Avatar
Ok I managed to fix the issue by changing the nesting
Answer