I am attempting to adjust the size of a UI chip dynamically based on the font size of its parent elements using the em
unit in CSS.
My objective is to achieve something like this:
style={{size:'1em'}}
The issue I'm encountering: The chip element in material-ui does not seem to be easily resizable compared to other components in material-UI.
Attempts made:
style={{transform:'scale(1em)'}}
was tried but it did not yield the desired outcome. The anchor point for the transform operation was difficult to manage.- Another approach involved creating a custom chip with
. However, this solution lacked the original appearance of the material UI chip.<img style={{float: 'left', width: '1em', borderRadius: '50%',}}/>
import Avatar from '@material-ui/core/Avatar'
import Chip from '@material-ui/core/Chip'
function Chips() {
const classes = useStyles()
const handleDelete = () => {
console.info('You clicked the delete icon.')
}
const handleClick = () => {
console.info('You clicked the Chip.')
}
return (
<div className={classes.root}>
<h1>
<Chip
//style={{size:'1em'}}
avatar={<Avatar alt="Natacha" src="/static/images/avatar/1.jpg" />}
label="Deletable"
onDelete={handleDelete}
/>
</h1>
<h4>
<Chip
//style={{size:'1em'}}
avatar={<Avatar alt="Natacha" src="/static/images/avatar/1.jpg" />}
label="Deletable"
onDelete={handleDelete}
/>
</h4>
</div>
)
}