Topic: input icon show in the middle
Hi there, I tried to use the MDBInput form with icon. But somehow after I put it into my react component, the icon becomes in the center of the field.
Expected behavior the Icon should be in the left like in the example
Actual behavior it goes to the middle
Resources (screenshots, code snippets etc.)
import React, { Component } from 'react';
import {MDBContainer, MDBRow, MDBCol, MDBInput, MDBBtn, MDBCard, MDBCardBody, MDBIcon} from 'mdbreact';
export default class ExpenseForm extends Component {
render() {
return (
<div>
<MDBContainer>
<i className="fa fa-user prefix" />
<MDBInput label="Material input" icon="user" />
</MDBContainer>
</div>
)
}
}
the result from code above:
Anna Morawska staff answered 6 years ago
Hi @ftansari ,
it's because one of the parent elements have a class text-center
or something similar which adds text-align: center
CSS rule.
To fix this add containerClass="text-left"
prop to the MDBInput component, like this:
import React, { Component } from 'react';
import { MDBContainer, MDBInput, } from 'mdbreact';
export default class ExpenseForm extends Component {
render() {
return (
<div>
<MDBContainer >
<MDBInput label="Material input" icon="user" containerClass="text-left" />
</MDBContainer>
</div>
)
}
}
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- User: Free
- Premium support: No
- Technology: MDB React
- MDB Version: 4.13.0
- Device: PC
- Browser: Chrome
- OS: Linux
- Provided sample code: No
- Provided link: No