In {NiceTabular}
of nicematrix
, you have a command \RowStyle
to specify formatting instructions for the current row.
\documentclass{article}
\usepackage{nicematrix}
\begin{document}
\begin{NiceTabular}{l|llll}
\RowStyle{\color{red}}
& 1 & 2 & 3 & 4 \\
\hline
1 & A & B & C & D \\
2 & A & B & C & D \\
3 & A & B & C & D \\
4 & A & B & C & D \\
\end{NiceTabular}
\end{document}

There is also a key color
for that command \RowStyle
. color=red
will insert \leavevmode\color{red}
with the \leavevmode
which is necessary in columns of type p
, m
, b
and X
(otherwise, there is an extra vertical space).
\documentclass{article}
\usepackage{nicematrix}
\begin{document}
\begin{NiceTabular}{l|p{1cm}p{1cm}p{1cm}p{1cm}}
\RowStyle[color=red]{}
& 1 & 2 & 3 & 4 \\
\hline
1 & A & B & C & D \\
2 & A & B & C & D \\
3 & A & B & C & D \\
4 & A & B & C & D \\
\end{NiceTabular}
\end{document}
