# Styling Rows

Canonical page: https://infinite-table.com/angular/docs/learn/rows/styling-rows

Rows can be styled by using the `rowStyle` and the `rowClassName` props

- the [`rowStyle`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#rowStyle) prop can be a style `object` or a `function` that returns a style `object` or `undefined`
- the [`rowClassName`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#rowClassName) prop can be a `string` (the name of a CSS class) or a `function` that returns a `string` or `undefined`

```tsx
const rowStyle: InfiniteTablePropRowStyle<Employee> = ({
  data,
  rowInfo,
}: {
  data: Partial<Employee> | null;
  rowInfo: InfiniteTableRowInfo<Employee>;
}) => {
  const salary = data?.salary ?? 0;

  if (salary > 150_000) {
    return { background: 'tomato' };
  }
  if (rowInfo.indexInAll % 10 === 0) {
    return { background: 'lightblue', color: 'black' };
  }
  return undefined;
};
```

The [`rowClassName`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#rowClassName) function prop has the same signature as the [`rowStyle`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#rowStyle) function prop.

The rows are rendered by the grid, not by the template of your component, so the styles of your component - which Angular scopes to its own template - don't reach them. Define the classes you return from [`rowClassName`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#rowClassName) in a global stylesheet (`src/styles.css`), or in a component with `encapsulation: ViewEncapsulation.None`.

## Row styling example

```ts
import { Component } from '@angular/core';

import { DataSource, InfiniteTable } from '@infinite-table/infinite-angular';
import type {
  InfiniteTablePropRowStyle,
  InfiniteTableRowInfo,
} from '@infinite-table/infinite-angular';

import { columns } from './rowStyle-example-columns.angular';
import type { Employee } from './rowStyle-example-columns.angular';

const rowStyle: InfiniteTablePropRowStyle<Employee> = (param: {
  rowInfo: InfiniteTableRowInfo<Employee>;
}) => {
  const { rowInfo } = param;
  if (rowInfo.isGroupRow) {
    return;
  }
  const { data } = rowInfo;
  const salary = data ? data.salary : 0;

  if (salary > 150_000) {
    return { background: 'tomato' };
  }

  if (rowInfo.indexInAll % 10 === 0) {
    return { background: 'lightblue', color: 'black' };
  }
  return undefined;
};

const dataSource = () => {
  return fetch(process.env.NEXT_PUBLIC_BASE_URL + '/employees100')
    .then((r) => r.json())
    .then((data: Employee[]) => data);
};

@Component({
  selector: 'demo-root',
  imports: [DataSource, InfiniteTable],
  template: `
    <infinite-data-source [data]="dataSource" primaryKey="id">
      <infinite-table
        debugId="rowStyle-example"
        [columns]="columns"
        [rowStyle]="rowStyle"
      />
    </infinite-data-source>
  `,
})
export default class App {
  protected readonly dataSource = dataSource;
  protected readonly columns = columns;
  protected readonly rowStyle = rowStyle;
}
```

In the [`rowStyle`](https://infinite-table.com/angular/docs/reference/infinite-table-props.md#rowStyle) function, you can access the rowInfo object, which contains information about the current row. It's especially useful when you have grouping and aggregation, as it contains the aggregation values and other extra info.
