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.

.mat-paginator-range-label styles is not customizable

See original GitHub issue

Bug, feature request, or proposal:

Bug (or proposal, I’m not sure).

What is the expected behavior?

MatPaginator range cannot be fully customize with CSS.

What is the current behavior?

MatPaginator range is fully customizable with CSS.

What are the steps to reproduce?

As I see, Angular Material engine isn’t adding tag attribute _ng... to div with class mat-paginator-range-label. So if there is any style in module style.css file it has no effect because of that tag attribute (_ng...) is added to style. Example, user module style.css:

.mat-paginator-range-label {
  margin: 0 !important;
}

The same style.css but after Angular processing, in browser:

  .mat-paginator-range-label[_ngcontent-c17] {
    margin: 0 !important;
  }

But div that I’ve talking about looks like: image

So the style.css gives no effect.

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

It’s more flexible (I guess).

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

"@angular/core": "^4.4.6",
"@angular/material": "^2.0.0-beta.12",
"@angular/platform-browser": "^4.4.6",
"@angular/platform-browser-dynamic": "^4.4.6",
...

"typescript": "~2.5.3"

macOS High Sierra, Safari, Google Chrome

Is there anything else we should know?

I don’t think so.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
shrraliscommented, Oct 28, 2017

@andrewseguin @willshowell you’re cool! Much thanks!

1reaction
willshowellcommented, Oct 27, 2017

@Shrralis as you mentioned, setting ViewEncapsulation.None will make all of your component’s styles globally effective. You have two options,

  1. Scope all of your un-encapsulated component’s styles with a scoped parent selector

    .only-affect-these-components {
    
      .mat-paginator-range-label {
        margin: 0;
      }
    }
    
    <div class="only-affect-these-components">
      <mat-table> ... </mat-table>
      <mat-paginator>...</mat-paginator>
    </div>
    

    And as the comment above mentions, you can add only-affect-these-components (or similar) to your host directly.

  2. Create a global style like this and add it to your global stylesheet

    // global styles
    .mat-paginator.marginless-paginator-range-label {
    
      .mat-paginator-range-label {
        margin: 0;
      }
    }
    
    <mat-paginator class="marginless-paginator-range-label">...</mat-paginator>
    

There is more information in this guide!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to customize mat-paginator in angular material
I need to revise the algorithm that calculates the range, the rendering of the buttons is still very glitchy, I will get this...
Read more >
Paginator | Angular Material
The labels for the paginator can be customized by providing your own instance of MatPaginatorIntl . This will allow you to change the...
Read more >
Customize Mat Paginator - StackBlitz
Starter project for Angular apps that exports to the Angular CLI.
Read more >
How to translate MatPaginator | by Mario Kandut - Medium
Customize the labels of MatPaginator in Angular`s Material Design Components ... unfortunately translating the paginator is not one of them.
Read more >
Angular 9 pagination example
Customize mat paginator CSS ... This paginator could be used to paginate anything, and it's not specifically ... Angular material paginator hide range...
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