Chips
"Mat chips" are components provided by Angular Material, designed for creating visually appealing and interactive chips or tags in a user interface. These chips are commonly used to represent discrete pieces of information or items that can be selected, filtered, or removed. Key features and characteristics of mat chips typically include:
Visual Representation: Mat chips provide a visually distinct representation of items or categories in the form of small, rounded rectangles. Each chip typically contains text or other content.
Interactive: Users can interact with mat chips, such as selecting, deselecting, or removing them by clicking or tapping.
Selection State: Mat chips often support selection states, making them suitable for implementing tags, filters, or multi-selection options.
Custom Styling: Angular Material provides theming and styling options that allow you to customize the appearance of mat chips to match your application's design and branding.
Accessibility: Mat chips are designed with accessibility in mind, ensuring keyboard navigation and screen reader compatibility.
Mat chips are commonly used in various contexts, including:
Tags: Representing tags associated with an item, post, or category.
Filters: Allowing users to filter and narrow down options.
Selection Controls: Enabling multi-selection of items in a list.
Input Components: Creating dynamic input fields with chips for adding items.
Here's a basic example of how you can use the mat-chip component in an Angular Material application:
The resulting output will appear as follows:
![](https://ed.sunbird.org/~gitbook/image?url=https%3A%2F%2F174969393-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FxNCrgHvEtBEHJOGTOcsQ%252Fuploads%252FJIApHdLhr4UsEv2bDpHt%252Fimage.png%3Falt%3Dmedia%26token%3Db518217f-a809-48a9-b41a-c354c3aefaca&width=768&dpr=4&quality=100&sign=f35846d4&sv=1)
Customization
In our application, we have implemented customized chips.
Before writing code in our HTML components, we initially imported and declared the MatChipsModule in "pills-grid.module.ts".
After importing the module, we proceeded to add the chips code in "pill-item.component.html"
We established a mixin named "theme-mat-chips" in "_mat-chips.scss" situated within the "mat-themes" folder. Subsequently, this "_mat-chips.scss" was imported into the "includes.scss" file.
A mixin was crafted and then imported into the "themes.scss" file within the "app-themes" section.
The end result will be as follows:
![](https://ed.sunbird.org/~gitbook/image?url=https%3A%2F%2F174969393-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FxNCrgHvEtBEHJOGTOcsQ%252Fuploads%252FnTdVEXJru2R1Ht4U5v5i%252Fimage.png%3Falt%3Dmedia%26token%3D32f24b3b-a423-4df5-ba9c-8ffae988c2e5&width=768&dpr=4&quality=100&sign=1d5631ca&sv=1)
Mat chips are a versatile and user-friendly way to manage and display categorized information or user selections in your application.
Last updated