Here is how you can create an input box using Material-UI v5 that has a blue dollar icon on the left and a red button on the right side inside the input field.
jsx Copy code
import React from 'react';
import { TextField, InputAdornment, IconButton, Button } from '@mui/material';
import { AttachMoney } from '@mui/icons-material';
function InputWithButtonAndIcon() {
return (
<TextField
variant="outlined"
placeholder="Enter amount"
InputProps={{
startAdornment: (
<InputAdornment position="start">
<AttachMoney style={{ color: 'blue' }} />
</InputAdornment>
),
endAdornment: (
<InputAdornment position="end">
<Button
variant="contained"
size="small"
style={{ backgroundColor: 'red', color: 'white' }}
>
Action
</Button>
</InputAdornment>
),
}}
/>
);
}
export default InputWithButtonAndIcon;
Explanation:
Result:
This will render an input field that looks something like this:
[image: Input with Dollar Icon and Red Button] open
On the left side , there's a blue dollar icon inside the input field.
On the right side , there's a red button labeled "Action" inside the input field.
Notes:
You can replace "Action" with any text you need on the button.
Adjust the style properties to fine-tune the appearance to match your design requirements.
Make sure to install @mui/material and @mui/icons-material packages if you haven't already:
bash Copy code
npm install @mui/material @mui/icons-material
Live Demo:
You can see a live working example on CodeSandbox .