Is there a way to modify a button's aspect ratio when it is clicked?

Currently, I am utilizing the MUI v5 AppBar to craft a navigation bar with Tabs. My aim is to have the background of the Tab blend seamlessly with the main page background upon being clicked, as illustrated here: https://i.sstatic.net/e4bDn.png

However, an issue arises where the Tabs are displayed as buttons and only center themselves within the appBar when activated. Adjusting the styling upon click to increase button height results in uniform growth across the entire button, failing to achieve the desired seamless blending effect with the rest of the page, as depicted here: https://i.sstatic.net/k9NdH.png

Is there a method to unevenly adjust the proportions of the buttons at the top and bottom? Furthermore, how can I ensure that the background of the button smoothly integrates with the remainder of the page without any visible shadows? Below is a snippet of my current code for reference:

            <Box
              sx={{
                textTransform: "none",
                flexGrow: 1,
                display: { xs: "none", md: "flex" },
              }}
            >
              <Tabs
                value={selectedTab}
                onChange={handleChange}
                TabIndicatorProps={{hidden: true}}
                sx={{
                  "& button": { borderRadius: 1 },

                  "& button.Mui-selected": {
                    color: "black",
                    backgroundColor: "#e5e5e5",
                    height: 70,
                   
                  },
                }}
              >
                <Tab value="one" label="Invoice" />
                <Tab value="two" label="Students" />
                <Tab value="three" label="Reports" />
              </Tabs>
            </Box>

I would greatly appreciate any input or solutions to these questions. Thank you.

Answer №1

Give this a try:


<Container
      sx={{
        textTransform: "uppercase",
        backgroundColor: "#295fab",
        flex: 1,
        padding: "0px 5px",
        paddingTop: "16px",
        display: { xs: "none", md: "flex" }
      }}
    >
      <Nav
        value={value}
        onChange={handleNavigation}
        NavIndicatorProps={{ hidden: true }}
        sx={{
          "& button": {
            borderRadiusTopLeft: 6,
            borderRadiusTopRight: 6,
            padding: "5px 25px",
            paddingTop: "16px"
          },

          "& button.Mui-selected": {
            color: "black",
            backgroundColor: "#e5e5e5"
          }
        }}
      >
        <NavItem value="one" label="Tasks" />
        <NavItem value="two" label="Calendar" />
        <NavItem value="three" label="Contacts" />
      </Nav>
 </Container>

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

Initiating the accordion feature requires two clicks and triggers an rotation of the icon

I managed to integrate some code I discovered for a FAQ accordion on my website. I am struggling with getting the title to expand with just 1 click instead of 2. Additionally, I would like the icon to rotate when expanding/collapsing, not just on hover. Be ...

Configuring the TradingView widget with NextJS Script

Struggling with transferring an article on my website from Jekyll to NextJS, I'm facing a roadblock in passing widget configuration to the built-in Script component. The widget doesn't display as it should. Below is the snippet of code causing th ...

Anomalous Snackbar and Alert Interactions

Why am I getting an error with this code snippet: import Snackbar from "@mui/material/Snackbar"; import MuiAlert from "@mui/material/Alert"; const Alert = ({children}) => <MuiAlert>{children}</MuiAlert> <Snackbar ope ...

Guide: Using jQueryUI's explode effect to animate an HTML element explosion

I'm having trouble getting the jQueryUI explode effect to work properly. I've tested it out on this jsfiddle, but the explosion effect doesn't seem to happen as expected - the element just disappears with no explosion animation. $('h1, ...

State not updating correctly in React Geosuggest component

I am currently working on developing a weather application and utilizing an external component called 'react-geosuggest'. The issue I'm facing is that when I update the input (refer to: onChange={this.onInputChange}), the function does not ...

Addressing see-through box styling in CSS

When working on a website using HTML and CSS, I encountered an issue with a transparent box. All elements within this box are also transparent, but I want them to be solid without any opacity. How can I resolve this? .parent { display: inline-block; ...

Issue with Refreshing onRowAdd in React Material Table

I am currently using Material Table to display my table data. However, when I use the onRowAdd function to add a new row, the page does not refresh properly. Instead, it reloads and gets stuck, requiring me to manually refresh again. newData => ...

Show search results as soon as the key is pressed

I am attempting to show search results for each key press in the input field: retrieveMovies(e){ axios.get(`http://www.omdbapi.com/?t=${e.target.value}`) .then((response) => { this.setState({ movies: response.data }); }) .catch((error) ...

Comparing adjust-leading-to with leader in Compass - what sets them apart?

Currently exploring Compass and feeling a bit puzzled about the functionality of two mixins: adjust-leading-to and leader. Would appreciate it if someone could clarify the distinction between them. ...

Adjusting the ng-bootstrap carousel to fit within a div inside an ng-bootstrap modal

I have been struggling to correctly adjust the CSS properties in order to make a ng-bootstrap carousel image fit into a specific space (div) within a custom ng-bootstrap modal. Take a look at this modified StackBlitz code. In the provided example, the ima ...

pressure exerted on the body

Recently, I've been working on a project for the website . One of the main issues I've encountered is that the <body> element is consistently 20px lower than it should be at the top. This has led to visible problems with the background grad ...

I am constantly reminded by React hooks to include all dependencies

Imagine I am using useEffect to pre-fetch data upon initial rendering: function myComponent(props) { const { fetchSomething } = props; ... ... useEffect(() => { fetchSomething(); }, []); ... ... } My linter is warni ...

The circular reference error message "Redux Action 'Type alias 'Action' circularly references itself" appears

I am currently working with two different actions: export const addToCart = (id: string, qty: number) => async ( dispatch: Dispatch, getState: () => RootState ) => { const { data }: { data: IProduct } = await axios.get(`/api/products/${id}`) ...

The Google Language Translator disregards the formatting

Currently, I am in the midst of developing a website with Wordpress and have successfully integrated Google Language Translator. Everything seems to be working well, except for one issue - when I translate the content, it alters the font size. Prior to tra ...

Getting the date from an object stored in MongoDB can be achieved by accessing the specific property

I'm developing an application that includes both chat and posts functionality. I want to display the timestamp of the most recent post in the chat. Below is a snippet from my mongoose schema for handling posts, along with an image illustrating how the ...

The Date object in Typescript is represented as a string

My typescript interface includes a variable called start, which is typed as Date | null. This data is retrieved from a dotnet API that returns a DateTime object. The issue arises when the start variable is passed through a function in Date-fns, causing a R ...

What steps can I take to troubleshoot and fix the issue of a Duplicate identifier 'DateType' error during the React/Typescript building process

Utilizing the MUI library, I have also installed the @mui/x-date-pickers library. In order for my datepicker component to function properly, I need to install the @date-io/date-fns/ library as well. However, upon running yarn build, I encountered the fol ...

The JavaScript code is not running as expected!

i have this index.html file: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" ...

Incorporate a hanging indent within the text enclosed by the <li> element

(revised multiple times to enhance clarity) Disclaimer: I did not create the HTML code. Below is the structure of the HTML (please note that the links and text following them are on the same line): <li> <strong>Heading of section</str ...

NextRouter does not have a property called "refresh"

Here is the provided code snippet: "use client"; import { useRouter } from "next/router"; import { useState } from "react"; export default function CreatePrompt() { const [title, setTitle] = useState(""); const ...