The positioning of Material UI InputAdornment icons is located beyond the boundaries of the TextField input area

I am struggling to understand why my InputAdornment is not positioned correctly.

There doesn't seem to be any style in my code that would affect the location of the icon within the TextField (such as padding or flex properties).

Currently, the calendar icon does not align properly with the text field input line.

This is how I want it to look - but with a calendar icon instead of 'kg' :)

Here are some snippets from my styles object:

const useStyles = makeStyles(theme => ({
    input: {
        '& input, textarea': {
            paddingTop: 8,
            paddingBottom: 12,
            fontSize: 15,
            marginTop: 15,
            '&:focus': {
                borderBottomColor: COLORS.BLACK
            },
            '&::placeholder': {
                fontSize: 15
            }
        },
    },
    ...
    dashboardInput: {
        '& .MuiInputLabel-root': {
            color: theme.palette.text.primary,
            fontSize: 16,
        },
        '& input, textarea': {
            borderBottom: `1px solid ${COLORS.BLACK}`,
            fontSize: 16,
            '&::placeholder': {
                color: theme.palette.grey[400],
            },
            '&:disabled': {
                color: COLORS.BLACK
            }
        },
        '& .MuiFormHelperText-root': {
            color: theme.palette.grey[500],
            fontSize: 10
        },
    },
   ...
    inputLimiter: {
        textAlign: 'right',
        fontSize: 10
    },
    ...
    },
}));

The relevant part of the component is shown below:

    <FormControl
        fullWidth
        className={classNames(classes.input, getInputStyle(appearance), {
            [classes.error]: error
        })}
    >
        <InputLabel shrink htmlFor={name}>
            <div className={classes.divcontrol}><div>{label}</div><div className={classes.redAsterisk}>*</div></div>
        </InputLabel>
        <TextField
            id={name}
            placeholder={placeholder}
            fullWidth
            multiline={multiline}
            rows={multiline ? rows : 0}
            type={type}
            style={style}
            inputProps={{
                maxLength,
            }}
            defaultValue={defaultValue}
            disabled={disabled}
            onChange={e => onChangeWithRightType(e)}
            InputLabelProps={{
                shrink: true,
            }}
            value={value}
            {...props}
            InputProps={{
                disableUnderline: true,
                endAdornment: (
                    <InputAdornment position="end">
                        <DateRange />
                    </InputAdornment>
                ),
            }}
            error
            helperText={helperText}
        />
        {maxLength && (
            <Typography variant="body2" className={classes.inputLimiter}>
                {value ? String(value).length : 0}/{maxLength}
            </Typography>
        )}
    </FormControl>

Answer №1

In response to your inquiry, I recommend toggling the disableUnderline setting in InputProps to true.

InputProps={{
              disableUnderline: true,
              ......
           }}

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

Is there a way to add a dynamic animation of steam rising from a coffee cup to my SVG icon design?

I'm a budding graphic designer eager to master the art of SVG animated icons and coding. Recently, I created an SVG file of a beautiful cup of coffee using Illustrator and now I want to make the steam rise realistically through animation. However, des ...

Utilize the provider within the decorator function

Essentially, the challenge I am facing is passing an authService to the "verifyClient" function within the @WebSocketGateway decorator. Here is how it should look: @WebSocketGateway({ transports: ['websocket'], verifyClient: (info: { req: Inc ...

Issue with using a variable for opacity in Tailwind CSS colors

const Home = () => { const variableOpacity = 0.85; return ( <> <main> <div className={`h-8 bg-primary/[${variableOpacity}]`}>85%</div> </main> </> ); ...

Achieving overflow behavior in a div with maximum height that contains another div with maximum height (Overflow issue persists)

Currently, I am utilizing Materializecss to showcase a modal window. Within this modal, there is a div Content that showcases items using ng-repeat. However, the issue arises when the content fills up and the css rule for my content-div fails to take effec ...

Transitioning from MVC to Angular 2 and TypeScript: A Step-by-Step Guide

Seeking guidance as I venture into the world of Angular. My goal is to pass a string variable 'element' to my UI and utilize it. However, I am unsure about how to go about passing it inside main.js and beyond. How can I transfer a variable to a t ...

How to display a PDF in Angular 6 using a byte array retrieved from a WebAPI

Having trouble opening a PDF from byte array sent by WebAPI. This is my Service: fetchPdfDocument(): Observable<any> { return this.httpClient .get(this.configuration.serverUrl + this.configuration.getPdfDoc, { re ...

Can you explain the role of the next() function in middleware/routes following the app.use(express.static(...)) in Express

When dealing with serving static assets generated from React source code using npm run build, the following method can be used: app.use('/', express.static(path.join(__dirname, 'apps', 'home', 'build'))) To protect ...

What is the best way to choose an element within a component's template?

Is there a way to access an element that is defined in a component template? While Polymer has the $ and $$ to make this task simple, I am curious about how it can be done in Angular. Consider the example provided in the tutorial: import {Component} from ...

Adjust the color of both the image and text when hovering over either one

I need help creating a hover effect for an image and text pair. My goal is to have the image change when hovered over, along with changing the color of the text next to it. Below is the code I am currently working with: <ul id="recherche"> < ...

Updating Redux Store when Clearing Input Options in MUI Autocomplete - Best Practices

When the user clears the input, I need to update the react-redux store. Thank you. <Autocomplete multiple id="tags-outlined" options={filters} onInputChange={(event, newInputValue, reason) => { dispatch(appActions.setFilter({ label: newInp ...

Implementing Angular 2 - Steps to ensure a service is accessible within the app module

I'm running into an issue trying to utilize a function within a service that I believed was globally accessible. The service in question is named SavedNotificationService: import { Injectable } from '@angular/core'; @Injectable() export cl ...

Adjusting the properties of a <span> tag when hovering over a different element

Query: I am trying to dynamically change the color of the span element with classes glyphicon and glyphicon-play when the user hovers over the entire element. How can I achieve this? Recommendation: .whole:hover > span.glyphicon.glyphicon-play { c ...

Prop in a React component is undergoing mutation

I encountered a strange situation where a prop in a React component is being changed. Although it's technically not a mutation since it's an array in JavaScript, it should not be modified. To replicate the issue, I created a simple example: htt ...

The challenge with the Optional Chaining operator in Typescript 3.7@beta

When attempting to utilize the Typescript optional chaining operator, I encountered the following exception: index.ts:6:1 - error TS2779: The left-hand side of an assignment expression may not be an optional property access. Here is my sample code: const ...

Is there a way to align the line under the hyperlinks to match the text size using CSS?

<div className={styles.container}> <ul className={styles.links}> <li className={styles.link}> <a href="/">Home</a> </li> <li className={styles.link}> <a href="/portfolio& ...

Tips for boosting ViteJs development mode performance

One issue I am facing is the slow server performance during development mode. After starting the server and opening the page in my browser, I have to wait 3–6 minutes for it to load! Initially, ViteJs downloads a small amount of resources, but then the ...

Using MUI Select with Array of Objects for values - Learn how to deselect a predefined state

I have a list of objects structured like this: [ { _id: "6311c197ec3dc8c083d6b632", name: "Safety" }, ........ ]; These objects are loaded as Menu Items options for my Select component: {categoryData && c ...

Sticky positioning for dropdown menu in table column body

Greetings, I need some assistance with a formatting issue. My goal is to make the first and second columns of my table sticky by applying a "sticky" position to them. However, one of the columns contains a dropdown menu and the problem is that the content ...

What are the key differences between using role and class selectors in HTML 5 and CSS3 to create two sidebars with three

My decision to eliminate all ids from my CSS and transition to HTML 5 has led me to question the use of roles in markup. In the past, IDs were used to style sidebars individually within a single selector for both. Here is an example: <div id="sidebar" ...

The deployment on Vercel is encountering an issue because it cannot find the React Icons module, even though it has been successfully installed

My attempt to deploy a project on Vercel is encountering an error during the building phase. The error message states that React icons cannot be found, even though they are installed in the package.json file and imported correctly in the component using th ...