Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use the `component` property on a React MUI Chip component?

I want to customize the label of a Material UI chip to have two text styles in the same label: bold text followed by regular text. I see from the docs that the API allows specifying something in the component property to override the structure of the chip, but I can't find an example of how to do that. What would that look like?

like image 900
adam0101 Avatar asked Jan 26 '26 09:01

adam0101


1 Answers

You can actually insert custom element to the label as label is type of node.

<Chip
  label={<div>Test<b>bold</b></div>}
  ...
/>

Using component:

const Test = (children) => {
  return (
    <div>testing</div>
  )
}


<Chip 
  component={Test}
  ...
/>
like image 55
fmsthird Avatar answered Jan 29 '26 00:01

fmsthird



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!