How to align text in a clarity datagrid

Viewed 1725

I have a angular app and i use clarity instead of bootstrap,

i have a datagrid and would like to know how you can align the header text of the datagrid to the center i have tried inline styling an css but doesn't seem to work.

code example html file

<clr-datagrid>
    <clr-dg-column class="align-content">User ID</clr-dg-column>
    <clr-dg-column class="align-content">Name</clr-dg-column>
    <clr-dg-column class="align-content">Creation date</clr-dg-column>
    <clr-dg-column class="align-content">Favorite color</clr-dg-column>

    <clr-dg-row >
        <clr-dg-cell>data</clr-dg-cell>
        <clr-dg-cell>data</clr-dg-cell>
        <clr-dg-cell>data</clr-dg-cell>
        <clr-dg-cell>data</clr-dg-cell>
    </clr-dg-row>
        <clr-dg-row >
        <clr-dg-cell>data</clr-dg-cell>
        <clr-dg-cell>data</clr-dg-cell>
        <clr-dg-cell>data</clr-dg-cell>
        <clr-dg-cell>data</clr-dg-cell>
    </clr-dg-row>
        <clr-dg-row >
        <clr-dg-cell>data</clr-dg-cell>
        <clr-dg-cell>data</clr-dg-cell>
        <clr-dg-cell>data</clr-dg-cell>
        <clr-dg-cell>data</clr-dg-cell>
    </clr-dg-row>

    <clr-dg-footer></clr-dg-footer>
</clr-datagrid>

css file

.align-content {
text-align: center;
}

thanks in advance

2 Answers

You can target datagrid-column-title class and can give it style like:

.datagrid-column-title{
  display: flex;
  justify-content: center;
}

Also if you want the data rows to be centered as well at the same time, try this:

.datagrid-table .datagrid-cell{
  display: flex;
  justify-content: center;
}

Make sure you do these changes in style.scss of your application.

Here's a working demo:https://stackblitz.com/edit/angular-tt3md6

Related