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

157
Visualizações
Material UI First Tab not showing up

I am having an odd issue where the first Tab is not displaying right. I had experimented around and added a 2nd tab, which shows up just fine. I basically made the 2nd tab have what I wanted the first tab to have. Since I thought that I might have made a mistake, I deleted the first tab and just had the 2nd tab be the first tab...only for it to not show up. Here is my code:

<Tabs
  value={value}
  onChange={handleChange}
  indicatorColor="primary"
  className={classes.tabContainer}
 >
    <Tab label="Today's Picture" />
    <Tab
      className={classes.tab}
      label="Today's Picture"
      component={Link}
      onClick={refreshPage}
      to="/"
    />
    <BasicDatePicker date={props.date} setDate={props.setDate} />
 </Tabs>

The first tab was me experimenting to see if it would show, the 2nd tab is what I want to show up as the first tab. The odd thing that was happening is that when it wasn't showing my first tab, at least hovering over it made the styling I have set up show, but not hovering over it made it look like nothing was there.

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

0

I have copied this code from material UI site and it will work fine try this:

    function TabPanel(props) {
  const { children, value, index, ...other } = props;

  return (
    <div
      role="tabpanel"
      hidden={value !== index}
      id={`simple-tabpanel-${index}`}
      aria-labelledby={`simple-tab-${index}`}
      {...other}
    >
      {value === index && (
        <Box sx={{ p: 3 }}>
          <Typography>{children}</Typography>
        </Box>
      )}
    </div>
  );
}

TabPanel.propTypes = {
  children: PropTypes.node,
  index: PropTypes.number.isRequired,
  value: PropTypes.number.isRequired,
};

function a11yProps(index) {
  return {
    id: `simple-tab-${index}`,
    'aria-controls': `simple-tabpanel-${index}`,
  };
}

export default function BasicTabs() {
  const [value, setValue] = React.useState(0);

  const handleChange = (event, newValue) => {
    setValue(newValue);
  };

  return (
    <Box sx={{ width: '100%' }}>
      <Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
        <Tabs value={value} onChange={handleChange} aria-label="basic tabs example">
          <Tab label="Item One" {...a11yProps(0)} />
          <Tab label="Item Two" {...a11yProps(1)} />
          <Tab label="Item Three" {...a11yProps(2)} />
        </Tabs>
      </Box>
      <TabPanel value={value} index={0}>
        Item One
      </TabPanel>
      <TabPanel value={value} index={1}>
        Item Two
      </TabPanel>
      <TabPanel value={value} index={2}>
        Item Three
      </TabPanel>
    </Box>
  );
}
about 4 years ago · Juan Pablo Isaza Relatório

0

I figured it out, once I changed this:

<Tab
      className={classes.tab}
      label="Today's Picture"
      component={Link}
      onClick={refreshPage}
      to="/"
    />

to this:

     <Tab
      className={classes.tab}
      value="Today's Picture"
      label="Today's Picture"
      component={Link}
      onClick={refreshPage}
      to="/"
     />

I basically had to add a value line in my Tab. Once I did that, it worked as intended!

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