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

132
Visualizações
Use mui icons between components in react

So I am trying to use mui icons between components.

I am using the <Icon /> component but there are two problems with that:

  1. Only half of the icon is rendered.
  2. I cannot style the icon in the component but instead have to style it where im using the component

src/components/sidebar/Sidebar.comp.js (Where im using the icon component)

import React from "react";
import twitterLogo from "../../images/twitter_logo.png";

import { Home } from "@mui/icons-material";
import { Link } from "react-router-dom";
import SidebarOption from "./SidebarOption.comp";

function Sidebar() {
  return (
    <div className="px-4 py-2 ">
      <div className="rounded-full transition-color cursor-pointer hover:bg-blue-100 px-2 py-3 w-max">
        <Link to="/home">
          <img src={twitterLogo} alt="twitter_logo" className="h-7" />
        </Link>
      </div>
      <SidebarOption
        MuiIcon={<Home style={{ fontSize: "2rem" }} />}
        path="/home"
      />
    </div>
  );
}

export default Sidebar;

./SidebarOption.comp.js (Where im creating the icon prop)

import React from "react";

import { Icon } from "@mui/material";
import { Link } from "react-router-dom";

function SidebarOptions({ MuiIcon, path }) {
  return (
    <div className="rounded-full transition-color cursor-pointer hover:bg-gray-300 p-[7px] w-max h-max">
      <Link to={path}>
        <Icon>{MuiIcon}</Icon>
      </Link>
    </div>
  );
}

export default SidebarOptions;

Thanks in advance!

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

0

You are using a combination of two APIs here. <Icon /> component is meant to be used for custom font icons, while the <Home /> icon (among others) is already ready-to-use as it is. Remove the wrapping <Icon /> component from SidebarOptions component and it should work.

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