Skip to content

BUG: mat-chip without mat-chip-list has no styles #9964

Closed

Description

@wiedikerli

Bug, feature request, or proposal:

Bug

What is the expected behavior?

<mat-chip> without parent <mat-chip-list> should render the same styles.
chip.scss is only injected to the <mat-chip-list> component.

What is the current behavior?

<mat-chip> has no styles.

What are the steps to reproduce?

add <mat-chip> to template without <mat-chip-list>
stackblitz

What is the use-case or motivation for changing an existing behavior?

i dont want to add the <mat-chip-list> if i render only one chip

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

angular: 5.2.2
material: 5.1.0
typescript: 2.6.2
os: *
browsers: *

Is there anything else we should know?

Activity

  1. donroyco commented on Feb 15, 2018

    @donroyco
    Contributor

    Weird thing is, when adding a mat-chip-list, it works correctly for all mat-chips.

  2. josephperrott commented on Feb 15, 2018

    @josephperrott
    Member

    This is happening because the mat-chip is a directive and without a view does not load styles or styleUrls. Once mat-chip-list is loaded, the chips styling is loaded and will be applied to all things it matches via css.

  3. Manostion commented on Jun 14, 2018

    @Manostion

    Heya,

    I'm pretty new to Angular and have only worked with AngularJS before. I wanted to try using the mat-chip-list component in a test project following the instructions on the official documentation but for some reason all of my chips receive the mat-basic-chip [edit: nevermind, it was mat-standard-chip] class and are thus unstyled. In addition they get extremely large for a second or so when I click them. This issue persists, even if I manually add styles for them, so this is my main issue, I guess.

    I know it's not this exact issue but I felt it was related. Does anyone know what I'm missing...?


    I have imported the module in my app.module.ts like so:

    ...
    import { MatChipsModule } from "@angular/material/chips";
    ...
    @NgModule({
      declarations: [...],
      imports: [
        MatChipsModule,
        ...
      ]
    })
    export class AppModule { }
    

    ...and my layout inside the app.component.html looks something like this:

    <div fxLayout="column">
      ...
      <div fxLayout="column" fxLayoutAlign="center center">
        <mat-card fxFlex fxFlexFill>
          ...
          <mat-card-content>
            <mat-chip-list>
              <mat-chip>My</mat-chip>
              <mat-chip>Awesome</mat-chip>
              <mat-chip>Chips</mat-chip>
            </mat-chip-list>
          </mat-card-content>
        </mat-card>
      </div>
    </div>
    

    Update / solved:
    My bad, I forgot to include a prebuilt Angular Material theme...

  4. striky1 commented on Aug 7, 2018

    @striky1

    Something new about that? Still not working. Thank you

    Angular v6.0.0
    Material v6.2.1
    TypeScript v2.7.2

  5. added
    P4
    on Aug 7, 2018
  6. jelbourn commented on Aug 7, 2018

    @jelbourn
    Contributor

    Agreed that it would be nice to have chips without a chip-list, but currently this would be a low priority issue.

  7. striky1 commented on Aug 7, 2018

    @striky1

    Thank you for your reply.

    Btw. I tried it with <mat-chip-list> and styles are missing too (I mean, styles for primary/accent/warn color), it is something changed? See example here:

    https://stackblitz.com/edit/angular-9vs2ga

    Thank you.

  8. frederikschubert commented on Aug 14, 2018

    @frederikschubert

    @striky1 The colors only appear when the selected property is set on the map-chip.

  9. striky1 commented on Aug 14, 2018

    @striky1

    @frederikschubert oh, u are right! Thank you so much ;)

  10. rivernews commented on Sep 16, 2018

    @rivernews

    Just if someone's wondering the same issue - even wrapping up <mat-chip> by <mat-chip-list> still won't apply theme styling e.g. typography.

    It turns out that you will need to again wrap the whole thing up by something else like <mat-card-content>.

    If you don't want to use chips within a card, you can wrap it up by <mat-form-field>. But then there's an unwanted underline under the chips. You can eliminate it by doing:

    mat-form-field.mat-form-field .mat-form-field-underline {
        display: none;
    }

    For applying colors to chips like primary/accent/warn, as @frederikschubert mentioned, the selected property does the work.

  11. 10 remaining items

  12. lorenzocovarrubiasjr commented on Sep 17, 2020

    @lorenzocovarrubiasjr

    Having the same issue, any update?

  13. am-awais commented on Jan 25, 2021

    @am-awais

    this needs to be resolved ASAP, I mean its 2020 and Angular material bugs still exists :(

  14. Frankkwizera commented on Mar 23, 2021

    @Frankkwizera

    Hey
    any update on this issue?!

  15. abbasharoon commented on May 31, 2021

    @abbasharoon

    Facing the same issue, adding <mat-chip-list></mat-chip-list> in template fixed it however it's a real time waste for a lot of people who encounter this problem for the first time. If it's not gonna be fixed then I will suggest it will be better to at least add an error message about <mat-chip-list> being a required parent for mat-chip

  16. Dzivo commented on Sep 5, 2021

    @Dzivo

    Is this still a thing after all these years omg 🗡️

  17. MoodyJW commented on Oct 26, 2021

    @MoodyJW

    Bug sitting around for almost 4 years. Not sure if I should be impressed or disappointed.

  18. crisbeto commented on Dec 30, 2021

    @crisbeto
    Member

    Will be fixed by #23931.

  19. youssefkri commented on May 26, 2022

    @youssefkri

    26 may 2022 and still not fixed

  20. fbalbinoribeiro commented on Jul 22, 2022

    @fbalbinoribeiro

    2022-07-22 and still not fixed

  21. alex-polosky commented on Oct 11, 2023

    @alex-polosky

    2023-10-11 and still not fixed

    The irony of myself not fixing open source code is not lost on me.

  22. crisbeto commented on Mar 20, 2024

    @crisbeto
    Member

    As far as I can tell this is fixed. See https://stackblitz.com/edit/oekksb?file=src%2Fexample%2Fchips-overview-example.html. The issue can be reopened if there's a repro.

  23. angular-automatic-lock-bot commented on Apr 20, 2024

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  24. locked and limited conversation to collaborators on Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4area: material/chipsneeds: discussion

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions