Skip to content

Add Customize Css Class to the Mat-Tab-Content and other Mat-X tags which are generated runtime #23685

Closed

Description

@angelaki

Found this old issue that has been unresolved closed: #9290.

I want to apply styles to specific mat-tab-bodys but classes on the mat-tab component aren't applied on the mat-tab-body - or actually nowhere; they just get lost.

How about just applying them there?

Activity

  1. added
    feature
    needs triage
    on Oct 5, 2021
  2. crisbeto commented on Oct 5, 2021

    @crisbeto
    Member

    Which element are you trying to apply the class on exactly? The mat-tab-body is an internal component that isn't available outside the MatTabModule.

  3. added
    needs: clarification
    and removed
    needs triage
    on Oct 5, 2021
  4. angelaki commented on Oct 5, 2021

    @angelaki
    Author

    Yeah, that's right. My problem is: right now I am not able to somehow mark a mat-tab-body depending on it's related mat-tab. In my case I'd like to disable the scrolling behavior (but only for one tab) since the component inside offers it's own.

    My current solution is css nth-child ... But ... I'd think you'd agree, that this is no solution 😉

    e.g.

    <mat-tab class="disable-scroll"> ... </mat-tab>

    with Css

    .mat-tab-body.disable-scroll { ... } or .mat-tab .disable-scroll .mat-tab-body { ... } - depending on how it get's rendered.

    The goal just is to apply styles to mat-tab-body (and it's children) depending on the html's <mat-tab>. Right now the space between the <mat-tab> and the label / body is some kind of blackbox.

  5. crisbeto commented on Oct 5, 2021

    @crisbeto
    Member

    You're right, we don't have a good way of doing this at the moment. You might be able to work around it using a lazy-loaded tab and wrapping the content in your own div with a specific class. See https://material.angular.io/components/tabs/overview#lazy-loading.

  6. added
    P3
    and removed
    needs: clarification
    on Oct 5, 2021
  7. angelaki commented on Oct 5, 2021

    @angelaki
    Author

    It least a good solution for now - thank you!

  8. angelaki commented on Oct 5, 2021

    @angelaki
    Author

    Sorry, a bit off-topic, but: can recycle of these template be controlled? I'd like to keep them, as soon as they've been created once.

  9. added 8 commits that reference this issue on Oct 5, 2021
    04df98b
    3229062
    f88d9db
    9090dba
    b6fbd97
    d9ed100
    672699e
    b2c4492
  10. added a commit that references this issue on Nov 20, 2021
    4a201fd
  11. added a commit that references this issue on Jan 15, 2022
    f10d245
  12. angular-automatic-lock-bot commented on Feb 15, 2022

    @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.

  13. locked and limited conversation to collaborators on Feb 15, 2022
  14. added a commit that references this issue on Apr 3, 2022
    211669c
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

    P3area: material/tabsfeature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions