Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

93
Vistas
MUI Tab indicator styling override

I am currently trying to customize the MUI tab so that the indicator instead of a line at the bottom is a background color. After research I have found that using the TabIndicatorProps and passing it a style of display:none gets rid of the indicator completely. backgroundColor:"color" changes the line color but I cant figure out how to change it from a line to the whole background.

Some possible solutions I tried but did not work was giving the TabIndicatorProps a height:100% This create the background but masks the text in the tab. After that giving it an opacity: .8 gives me the effect I want but the text is too dark and I can't get it to change as the tab is active.

Expected Tab Image Current Tab Image

<Box sx={{ width: '100%', bgcolor: 'background.paper' }}>
            <Tabs TabIndicatorProps={{
                style: {
                    backgroundColor: '#D2603D',
                    borderRadius: '5px',
                },
            }} value={value} onChange={handleChange}>
                <Tab textColor='blue' onClick={handleClick} sx={{
                    backgroundColor: '#F4F5F9',
                    borderRadius: '5px',

                }} label="Daily" />
                < Tab sx={{
                    backgroundColor: '#F4F5F9',

                }} label="Weekly" />
                <Tab sx={{
                    backgroundColor: '#F4F5F9',
                    borderRadius: '5px'
                }} label="Monthly" />
            </Tabs>
        </Box >
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I don't think that is possible in a clean way. Either quite dirty workarounds or substantial re-implementation of the functionality is necessary.

The tab labels are <button> elements, the tab indicator is a <span> that lies above these buttons, but you want the labels appear above the indicator. So you have to either rearrange the stacking of the HTML elements, or add a second label above the indicator.

It is not possible to let the tab indicator slide behind the button text, but in front of the button background.

Some suboptimal ("dirty") workarounds

  1. You could re-arrange the stacking of the HTML elements.

This can be done by using z-index. You have to set the z-index of the buttons, and you need to keep the button background transparent.

Note that you might have to be careful if there are other elements which already have a z-index, or should stay behind the buttons, in which case you would need to change the z-index of these other elements as well.

<Tab label="Daily" style={{ zIndex: 1 }} />
<Tab label="Weekly" style={{ zIndex: 1 }} />
<Tab label="Monthly" style={{ zIndex: 1 }} />
  1. You could add the current label as a children of the tab indicator, and set the style to match the original label. You would also need to pass the current label, and the label would slide with the indicator, or the indicator would be empty while sliding.
const IndicatorLabel = ({ label }) => {
  return <span className={'indicator-label'}>
    { label }
  </span>;
};

// ...

<Tabs
  TabIndicatorProps={{
    // ...
    children: <IndicatorLabel label={ currentLabel } />
  }}
>

// ...
  1. You could set the background color of the <button> dynamically, and not use the indicator at all. Of course, you would lose the sliding effect.

  2. Of course, you could implement you own tab indicator from scratch, and don't use the MUI tab indicator.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda