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

278
Visualizações
react material-ui upload button look weird

I followed this MUI document

however, the results look different. The UI appeared with the button UI. This should show only the button UI, no UI.

enter image description here

I know i can handle this problem by add sx={{diplay:'none'}} propery, and It is work!

I'm just wondering if there is a mistake I made or if anyone is experiencing this problem.

below is my code

import React from 'react'
import { Button, Box, Stack, Input, Typography, IconButton } from '@mui/material'
import { PhotoCamera, Delete, Send, Alarm, AddShoppingCart } from '@mui/icons-material'

function PlainButton() {

  return (
    <Stack spacing={3}>
        <Box>
            <Typography sx={{marginTop:1, marginLeft:1}}>Upload Button</Typography>
            <label htmlFor="contained-button-file">
                <Input accept="image/*" id="contained-button-file" multiple type="file"/>
                <Button variant="contained" component="span">
                    Upload
                </Button>
            </label>
            <label htmlFor="icon-button-file">
                <Input accept="image/*" id="icon-button-file" type="file" sx=/>
                <IconButton color="primary" aria-label="upload picture" component="span">
                    <PhotoCamera />
                </IconButton>
            </label>
         </Box>
    </Stack>
  )
}

export default PlainButton

this is my version info

react version : 18.2.0
@emotion/react: 11.9.3
@emotion/styled: 11.9.3
@mui/icons-material: 5.8.4
@mui/material: 5.8.4

the browser is chrome

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

0

On MUI documentation they are also using display: none as you can see here:

import { styled } from '@mui/material/styles';
import Button from '@mui/material/Button';
import IconButton from '@mui/material/IconButton';
import PhotoCamera from '@mui/icons-material/PhotoCamera';
import Stack from '@mui/material/Stack';

const Input = styled('input')({
  display: 'none',
});

export default function UploadButtons() {
  return (
    <Stack direction="row" alignItems="center" spacing={2}>
      <label htmlFor="contained-button-file">
        <Input accept="image/*" id="contained-button-file" multiple type="file" />
        <Button variant="contained" component="span">
          Upload
        </Button>
      </label>
      <label htmlFor="icon-button-file">
        <Input accept="image/*" id="icon-button-file" type="file" />
        <IconButton color="primary" aria-label="upload picture" component="span">
          <PhotoCamera />
        </IconButton>
      </label>
    </Stack>
  );
}
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