question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change chip code to allow custom close buttons

See original GitHub issue

I think it would be useful to have the option of using any HTML element as a close button for a chip. With the current implementation, any of the Materialize icons that you put inside a chip automatically become a close button. This is handy if that’s all you want to do, but if you plan on having an icon in there for another reason, it’s highly annoying to have to modify things every time you want to do that. Also, you might want to have another element (an image, for example) close the tag. I have both of these use cases in my project, so I made a small modification to materialize.js to make it possible.

On line 3284, I changed it so that the line is this:

$(document).on('click.chip', '.chip .close-chip-btn', function (e) {

Rather than the original. This worked well for me (despite my limited knowledge of jQuery) so I figured I’d see if anyone else thought it was a good idea. If I’m not contributing this suggestion “properly” you’ll have to pardon me, I’m relatively new to GitHub so I’m “flying blind” here. Correct me if I did anything stupid. 😝

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:8

github_iconTop GitHub Comments

2reactions
Riaricommented, Jan 8, 2016

Good idea. I’d like to have more control over chip icons as I’m trying to use them like this:

a6exvct

It’s problematic having them close regardless of what the icon is.

1reaction
devmetalcommented, Jun 18, 2017

@TetianaP

Hi, i working on a project with materialize and react. I got the same issue when i try to make stateful this little component. I have to remove the close class also but this is the css code and its working for me:

<i
   onClick={() => onRemove(topic)}
   className="removable material-icons">
      close
</i>
i.removable {
  cursor: pointer;
  float: right;
  font-size: 16px;
  line-height: 32px;
  padding-left: 8px;
}

For now, i can hanle the active tags state in my component avoid the big errors 😃 Hope its help 😃

[Edited] The css from the materializecss library.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to add close icon button to mat-basic-chip in Angular ...
You can click the view source button in the offial docs to se how they have done it. They add a mat-icon in...
Read more >
How to customise SfChip close button glyph?
You can customize the close button glyph by using the Content support in SfChip and SfButton as per in below code snippet ...
Read more >
React Buttons Library & Chip Component - Customization
Customization. The Chip component provides the following options for customizing its look and feel: Display avatar, custom classes and icons; Select icon ...
Read more >
Chips – Material Design 3
Chips allow users to enter information, make selections, filter content, or trigger actions. While buttons are expected to appear consistently and with familiar ......
Read more >
Buttons - Menus and actions - Components - Human ...
In addition to all-purpose buttons, many common button styles — like Info, Close, and Contact Add — enable familiar behaviors throughout the system....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found