I'm working on a CSS project and my goal is to ensure that all the items are perfectly aligned in a

I have been working on a ReactJS code and I'm struggling to achieve the desired result. Specifically, I am using Material UI tabs and I want them to be aligned in line with an icon. The goal is to have the tabs and the ArrowBackIcon in perfect alignment, similar to what you can see in this image:

Desired Result: https://i.sstatic.net/paNWb.png


This is what I currently have: https://i.sstatic.net/TXVF6.png


Below is the CSS section for reference:

.MuiTabs-root {
    margin-bottom: 10px;
    border-bottom: 1px solid black;
}

.tab__section {
    display: flex;
    flex-direction: column;
}

.tab__section>.MuiSvgIcon-root {
    margin-top: 12px;
}

.MuiTabs-flexContainer {
    display: flex;
    align-items: center;
    justify-content: center
}

And here's the corresponding ReactJS code snippet:

const [selectedTab, setSelectedTab] = useState(0);

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

<div className="tab__section">
    <ArrowBackIcon />

    <Tabs 
        value={selectedTab} 
        onChange={handleChange}
        TabIndicatorProps={
            {
                style: {
                    backgroundColor: "blue",
                    height: "4px",
            }
        }}
    >
        <Tab label="Synchronize Cabinet"></Tab>
        <Tab label="Schedule Information"></Tab>
    </Tabs>

    {selectedTab === 0 && <SyncCabinet />}
    {selectedTab === 1 && <ScheduleInfo />}
</div>

Answer №1

The class tab__section is not suitable for achieving the desired UI. Additionally, it is recommended to eliminate the margin-top from the icon. A more appropriate solution would be:

.tab__section {
    display: flex;
    align-items: center;
    justify-content: space-between
}

Answer №2

Remove margin-top for icon and include align-items: center in tab__section

.tab__section {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

Attempting to test the FormControlLabel component in Enzyme does not seem to properly trigger a click event when using

Struggling with testing the FormControlLabel component from material UI as Enzyme won't fire a click event when simulating. Experimented with shallow, createShallow, mount, and createMount methods without success. Upon debugging, extracted the check ...

When utilizing Ref in a functional component, it may lead to obtaining NaN when trying to access the

I encountered a problem when trying to reference the same canvas element in both a class component and a functional component. In the class component, the canvas element is accessed using this.refs.canvas, while in the functional component, I had to use us ...

Error components are missing, please refresh the page. This message is specific to Next.J

After each pull, I always follow the same steps: git init git pull npm i or npm install Initially, all pages function correctly as expected. However, when transitioning from one page to another on localhost, I encounter this error: missing required error ...

Utilizing Python Selenium to Interact with Buttons

Encountering an issue while trying to use Selenium to click on a tab or button within my web application. Below are the code snippet and CSS selectors: Error message: selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: #t ...

What could be causing my border to spill over into the adjacent div?

Trying to set up the contact section of my portfolio but running into an issue where the border of one div is overflowing into the next. Here's a snippet of the code: //CSS .contact-cont { padding: 4rem 12rem 0rem; height: 90vh; ...

Problems with the main title formatting in the header

I am currently working on a new website and have encountered an issue with the header design. The Mainline "PersIntra" is overlapping the "log out button" box, which I would like to be positioned beside it instead. Despite my efforts with CSS and nesting ...

Ensure that the text inside the button does not exceed its boundaries (utilizing Bootstrap v4)

My current code snippet appears below. <div class="col-xl-2 col-lg-12"> <button class="btn btn-secondary w-100" value=1>But.</button> </div> <div class="col-xl-4 col-lg-12"> <button cla ...

Executing password validation on login/register form using Node.js and EJS

In order to demonstrate a simple login page, I have created a form that requests typical information like username, password, etc. Additionally, it prompts the user to confirm their password, and if the lengths do not match, an error is triggered to notify ...

Global Declaration of Third-Party Modules for Seamless Use without Imports in Webpack5 with TypeScript

Within my React project utilizing Webpack, I have opted to declare certain modules as global entities to eliminate the need for importing them every time they are needed. In my Webpack configuration file: plugins: [ new webpack.ProvidePlugin({ ...

Having trouble downloading a PDF file on a local server with React and the anchor tag element

Having trouble downloading a pdf file from my react app to my Desktop. I've reached out for help with the details How to download pdf file with React. Received an answer, but still struggling to implement it. If anyone new could provide insight, that ...

The align-content property in CSS Flex does not function properly when used alongside an inline height declaration

I encountered an issue with the CSS Flex property align-content. It seems to not work properly in a container where the height is declared inline. However, once I move the inline height declaration to a separate CSS class, everything works fine. Both Chrom ...

Acquiring administrative authorization upon user login with PHP

I have developed a registration form and a login form using PHP. However, whenever I run this code, it displays the message "invalid username" when the username is invalid, or it says "your account isn't approved by admin yet." Can anyone please guide ...

Implementing a pull-to-refresh feature in React Native using Redux

I need to implement pull to refresh functionality, but I'm unsure of what to call from _Refresh(). My actions, constants, and reducers are stored on another page. How can I trigger the API again? Thank you in advance for your assistance. class Homewo ...

A Complication Arises with Browser Functionality When Embedding an Iframe within

I am experiencing a peculiar problem while embedding an iframe with a specific src inside an absolutely positioned div. Here's the basic structure of the webpage: .container { position: relative; overflow: hidden; width: 100%; heigh ...

Is it possible to implement the 'opacity' feature on the homepage of my HTML website?

I am currently working on my website and I would like to display a notice to members when they open the site. This notice should only appear once, right above the HTML homepage, as the homepage content may vary for different members. I plan to use 'op ...

Striking a balance between innovation and backward compatibility in the realm of Web Design/Development

Creating websites is my passion, and I enjoy optimizing them for various platforms, devices, and browsers. However, lately, I've been feeling frustrated. I'm tired of facing limitations in implementing my creative ideas due to outdated technolog ...

What's the simplest method for adjusting the default font in Reactstrap?

Currently working on a MERN project and I want to customize the font used by Reactstrap for my React frontend. While I've come across solutions for altering Bootstrap 4's default fonts, I'm unsure how to implement them in Reactstrap. Any gui ...

Show Struts2 error message on an HTML webpage

I have included error and message handling in my Struts2 action class using the addActionMessage and addActionError methods. I am now looking for code that will allow me to display these messages and errors on the HTML page. Is it feasible to do so? ...

button that takes you back to the top of a mobile website

I want to customize the Scroll To Top button so that it only appears once the user begins scrolling down, rather than always being visible even when at the top of the page. Just a heads up, I don't have much experience with JavaScript, so I might need ...

Issues with hover styles and transitions not being correctly applied to newly appended elements in Firefox

Utilizing an SVG as an interactive floor plan, I have implemented a feature where hovering over different areas on the floor plan (<g> elements) causes them to expand and float above other areas. The element scaling is triggered by CSS, but I use jQu ...