I would like to change the color of the chapter label (small rectangle box) everytime I call the command \chapter{}, possibly passing the color as an argument.
Thus the part I need to address with the argument is the command \draw[fill=black].
Here a compilable example:
\documentclass{book}
\usepackage{color}
\usepackage{tikz}
\usepackage[explicit]{titlesec}
\newcommand*\chapterlabel{}
%\renewcommand{\thechapter}{\Roman{chapter}}
\titleformat{\chapter}[display] % type (section,chapter,etc...) to vary, shape (eg display-type)
{\normalfont\fontsize{24}{26}\bfseries} % format of the chapter
{\gdef\chapterlabel{\thechapter\ }} % the label
{0pt} % separation between label and chapter-title
{\begin{tikzpicture}[remember picture,overlay]
\node[yshift=-8cm] at (current page.north west)
{\begin{tikzpicture}[remember picture, overlay]
\draw[fill=black] (0,0) rectangle(35.5mm,15mm);
\node[anchor=north east,yshift=-7.2cm,xshift=34mm,minimum height=30mm,inner sep=0mm] at (current page.north west)
{\parbox[top][30mm][t]{15mm}{\raggedleft $\phantom{\textrm{l}}$\color{white}\chapterlabel}}; %the black l is just to get better base-line alingement
\node[anchor=north west,yshift=-7.2cm,xshift=37mm,text width=\textwidth,minimum height=30mm,inner sep=0mm] at (current page.north west)
{\parbox[top][30mm][t]{\textwidth}{\color{black}#1}};
\end{tikzpicture}
};
\end{tikzpicture}
\gdef\chapterlabel{}
} % code before the title body
\usepackage[utf8]{inputenc}
\title{test}
\begin{document}
\maketitle
\chapter{Introduction}
\end{document}
I tried to pass the argument to the \chapterlabel function but didn't work. I also found a very similar question "https://tex.stackexchange.com/questions/641554/change-color-for-each-chapter" that didn't really received an answer (I tried the solution proposed but didn't work).
I would be really greatful if someone can help.
