Customizing Thickness for Tab Labels in MUI 5

I have been trying to adjust the thickness of the label inside a tab using MUI 5, but so far I haven't had success. Here is what I have attempted:

interface TabPanelProps {
    children?: React.ReactNode;
    index: number;
    value: number;
}

function TabPanel(props: TabPanelProps) {
    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>
    );
}

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

export default function UsersGroupsManagement() {
    const [value, setValue] = React.useState(0);
    const handleChange = (event: React.SyntheticEvent, newValue: number) => {
        setValue(newValue);
    };

const StyledTab = styled(Tab)<TabProps>(({theme}) => ({
    '& .MuiButtonBase-root-MuiTab-root': {
        fontWeight: 'bold'
    }
}));

const styledLabel = styled('label')({
    color: 'darkslategray',
    backgroundColor: 'aliceblue',
    padding: 8,
    borderRadius: 4,
});

return (
    <Box sx={styles.userAccounts}>
        <Box sx={styles.tabbox}>
            <Tabs value={value} onChange={handleChange} aria-label="User Management Tabs" >
                <Tab label="ADD NEW USER" {...a11yProps(0)} sx={{
                    '& .MuiButtonBase-root-MuiTab-root': {
                        color: 'black',
                        backgroundColor: 'red',
                        fontWeight: 'bold'
                    }
                }}/>
                <Tab label="MANAGE USERS" {...a11yProps(1)} sx={{
                    '& .MuiButtonBase-root-MuiTab-root': {
                        fontWeight: 'bold'
                    }
                }}/>
            </Tabs>
        </Box>
        <TabPanel value={value} index={0}>
                <AddNewUser />
            </TabPanel>
            <TabPanel value={value} index={1}>
                Item Two
            </TabPanel>
        </Box>
    );
}

Despite my attempts with StyledTab and styled label not working, I also tried applying CSS through sx props without any luck.

Could you provide guidance on how to achieve thicker labeled tabs in Material UI v5?

Answer №1

Here is an example of how you can structure it:

    <Tabs
      sx={{
        "& .MuiTabs-indicator": { backgroundColor: "#E86826" },
        "& .MuiTab-root.Mui-selected": { color: "#E86826", fontWeight:"700" },
      }}
      value={value}
      onChange={handleChange}
      aria-label="nav tabs example"
      centered
    >

You just need to customize the tabs and your work will be completed. Hope this helps!

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Illustrate an element positioned beneath a child element within a different element

I am in the process of designing an overlay on a Google Map that resembles a real map placed on a table, using 2 pixel lines as creases above the map. This design does not significantly impact interactions with the map; only 6 out of 500 vertical lines are ...

Issues with Opera displaying specific characters when using webfonts

Perhaps it's not supposed to work this way, but hear me out. I'm utilizing Google Web Fonts and adding the PT Sans font like this: <link href="https://fonts.googleapis.com/css?family=PT+Sans:regular,italic,bold,bolditalic" rel="stylesheet" ty ...

Guide to efficiently inserting data into a table using mapping and conditional operators in JSX

Currently, I am working on integrating dynamic data from a web API into tables using material-ui/react. While I have the necessary data, the challenge lies in my unfamiliarity with JSX syntax. Coming from a Java background, JSX is proving to be difficult ...

What is the method for accessing Firebase config variables within React code?

Currently in the process of transitioning from Netlify to Firebase Hosting and encountering an issue with my .env environment variables disappearing after a few minutes of being hosted on Firebase. While researching, I discovered that Firebase uses 'c ...

Issue encountered while attempting to start React and Node.js: NPM error

I've encountered some errors in my Node.js and React.js project. I have a server and a React SPA, both working independently. When I use "concurrently" to start them together, I get the following errors: [0] npm ERR! missing script: servernpm run clie ...

Error: The FactoryMethod.render() function requires a valid React element to be returned, or null

An error has occurred: Error: FactoryMethod.render(): A valid React element (or null) must be returned. You may have returned undefined, an array, or some other invalid object. at invariant (react-dom.js:17896) Despite everything being fine during co ...

The dimensions of the pop-up window in Chrome's JavaScript are not displaying correctly

My goal is to launch a new chat room window on our website. The dimensions of the chat room are set to 750px x 590px. Below is the link I am using to trigger the javascript popup. <a href="javascript:void(0)" onclick="window.open('http://gamersuni ...

Instructions on adding a solid border color to a circular div using CSS

Hey there! I'm curious, is it possible to style a straight border color on a rounded div using CSS? Here I have some basic Tailwind CSS code. <div class="rounded-2xl w-72 h-20 border-l-4 border-l-yellow-500"> ... </div> In the ...

Slow rotation in CSS styling

.badge { -webkit-transform-style: preserve-3d; -webkit-perspective: 1000; position: relative; } .back, .front { position: absolute; -webkit-backface-visibility: hidden; -webkit-transition: -webkit-transform 1s ease-in; width: ...

"Responsive header design using Bootstrap for both desktop and mobile devices

Is there a way to create a header that adjusts its width based on the device viewing it, with maximum width for desktop and no padding for mobile? Here is an example of the code: <div class="row"> <div class="span12"> ...

The functionality to disable the ES lint max length rule is malfunctioning

In trying to disable an eslint rule in a TypeScript file, I encountered an issue with a regular expression that exceeded 500 characters. As a result, an eslint warning was generated. To address this, I attempted to add an eslint comment before declaring th ...

The issue of the back button not functioning in the React Multi-level push menu SCSS has

I have been developing a mobile-friendly Multi-level push navigation menu for my website using dynamically generated links based on projects from my GitHub account. I found a push menu on CodePen here and am in the process of integrating it into React inst ...

Comparing MUI Components to React Bootstrap Technologies

Hello everyone! I'm currently working on a project with react js and I have a question for you all. Do you think it's excessive to combine MUI Components and React Bootstrap in the same app? ...

Using Ant Design with Formik to dynamically set field values in a form

When I click the "Change" button in an Antd table with data, the entire line of data is passed to a function as an object. However, I am having trouble inserting the data into the fields. What should I do? How can I set data to Antd input using an externa ...

Are MobX Observables interconnected with RxJS ones in any way?

Is the usage of RxJs observables in Angular comparable to that in React and MobX? I'm struggling to find information on this topic. ...

Changing the context results in the entire component being re-rendered

Currently, I am encountering a challenge where I have two different components within my Layout.js component that need to "share" props with each other. To address this issue, I introduced a ContextProvider named IntegrationProvider. However, a new proble ...

The conditional ng-class styling will be applied to each and every div on the page

For a patient, I have a modal displaying a list of card numbers. If the card is set as the default card, it should have a grey background, based on a true value for the object. <td ng-repeat="obj in paymentAndShipping"> <div ng-click= ...

Is there a way to increase the spacing between the titles of these progress bars?

Ensure your responsiveness by enabling the Toggle Device Toolbar on your browser I'm attempting to create a progress bar, but I'm facing some challenges. Firstly, I want to increase the height of the semi-transparent black background, but I can& ...

Styling your components with Material-UI Theming and Styled Components

I am currently delving into Gatsby and experimenting with building components using Material-UI and Styled Components while applying my custom theme. I managed to successfully apply a theme by following the Gatsby configurations for the Material-UI plugin ...

spark of unique substance

Having trouble with cycle2 as all images are briefly displayed when the page loads. I tried the recommended solution http://jquery.malsup.com/cycle/faq.html but it didn't stop the flashing, indicating a different issue: The suggested fix for Cycle is ...