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

Unable to highlight text within a div container

I am currently facing an issue with my layout that involves three columns stacked to the left and four inner columns with three floated left and one floated right. This configuration is causing a problem where I cannot select any text on the page. Removing ...

What can be done when "create-react-app my-app" does not create the my-app project as expected and displays an error?

I managed to successfully set up create-react-app on my system. However, I encountered some issues when trying to create a new project using the command create-react-app my-app. The errors that appeared were: npm ERR! Maximum call stack size exceeded npm ...

The function onSpotifyWebPlaybackSDKReady has not been declared

Currently, I am in the process of creating a replica of Spotify using NextJS and React. My intention is to utilize the Web Playback SDK for track playback. However, every time I try to import the SDK script, it returns an error stating that it is not defin ...

What is the best way to showcase information from an external API in react js?

As I develop my new app, I am integrating API data from . This feature will enable users to search for their favorite cocktail drinks and display the drink name fetched from the API on the page. However, I am encountering an error that says "Uncaught TypeE ...

Arranging links in a horizontal line (JSFiddle)

CodePen: https://codepen.io/example/abc123 I am attempting to align the elements "Favourite", "0", and "Reply" next to each other so they appear as: Favourite 0 Reply ...

Having trouble with react-unity-webgl integration in Next.js project

I've been trying to integrate this code into a Next.js build, but for some reason the game isn't loading on the page and I'm not seeing any errors in the console. I'm completely stumped as to why the game won't load. The tools I&a ...

The background-color of a single child within an absolutely positioned element in Chrome may not be displayed if the element has a z-index and overflow scrolling

This test page has been created to showcase the issue: <html> <head> <style> .panel { position: absolute; width: 326px; max-height: 200px; overflow: scroll; z-index: 1000; } .item-container { width: 100%; list-style: none; ...

Please refrain from displaying slider images using react with react-slick

I've been working on a new .js project and decided to incorporate react-slick for the carousel feature. After installing both the react-slick and slick-carousel packages, I implemented the necessary CSS for the carousel: import React from "react& ...

Switch from Index.html to Index.html#section1

Currently, I am working on a website and sending someone a draft for review. However, the Home screen is designed as a 'a href' link with "#home". The issue arises when the website opens from my computer; it goes to ...../Index.html instead of .. ...

Utilizing Typescript Generics in Arrow Function to Combine Two Arguments

For instance, I am working with this code in a .tsx file extension const Add = <T,>(arg0: T, arg1: T): T => arg0 + arg1; const A = Add(1, 2); const B = Add('1', '2') However, I am encountering an issue, as there is an error m ...

Setting up routes in React and Rails configuration

I am currently working on developing a simple todo application using rails 4 and react. This project is geared towards helping me learn how to integrate react with rails, but I am facing some challenges when it comes to coding my rails controllers. As ...

Utilize ngClass for every individual section

I have completed the implementation of all UI components, which are visually appealing. Here is the data structure I am using: public filters = [ { tag: 'Year', label: 'year', items: [200 ...

Transfer ERC20 tokens along with an Ethereum transaction

Is there a way to specify the ETH value for a transaction when using the "useContractWrite" hook? I need to send both ETH and ERC20 tokens. I am having trouble with nesting elements, asynchronous calls... I'm not sure how to handle this in wagmi. Any ...

What sets @mui/material apart from @mui/system?

While using MUIv5, I came across this documentation link but I'm still confused about the disparity between @mui/material and @mui/system. Specifically, I am referring to their utility in utilizing the styled feature. It appears that they are used i ...

The Next JS Custom Server does not transfer the query to a component when using app.render

When using app.render to pass userData, I am facing an issue with Server side rendering where router.query is empty, despite passing userData! I'm unsure if this is a bug in NextJS or if I am making a mistake somewhere. Can you help? app.js: const { ...

How can I float a square to the right in Bootstrap with a col-md-4 size but with a height restricted to only 200 px

Looking to add a small square on the page for users to search and purchase courses directly. The square should be 4 columns wide, follow Bootstrap4 grid template, and be around 200-300 px in length. It needs to remain visible as the user scrolls down the p ...

Setting up module aliases in a monorepo initiated with Turborepo: a step-by-step guide

Currently working on migrating multiple repositories to the monorepo architecture using a POC bootstrapped with Turborepo. Facing an issue with misconfigured ts module aliasing. Have a single ui package where I am attempting to export a button component fr ...

Button within the Magnific Popup (do not use to close)

I am currently developing a website with a gallery page that utilizes the Magnific Popup plugin. My client has provided lengthy 'captions' for each image, almost like short stories. To display these captions effectively, I have utilized the titl ...

Attempting to highlight a specific list item by using the CSS current class to emphasize its active state

I've been experimenting with different solutions I found in previous questions, but unfortunately, none of them have worked for me. I suspect the issue lies in the fact that the element is deeply nested within CSS classes, and my lack of experience is ...

Utilizing Bootstrap and flexbox to create a card: repositioning the image to the left or right

Currently, I am attempting to construct a card layout using Bootstrap 4 with flexbox enabled. The image below depicts my current implementation, which is functioning as expected. https://i.sstatic.net/huXvo.jpg Here is the HTML structure: <section> ...