I've been trying to add some color swatches to the header. So far I've tried Tikz with the usual header commands of scrlayer-scrpage, but it didn't work out well. I almost did it, but two problems remain:

1. There is effectively no "background", the layer hides the header content;
2. The headers aren't symmetrical (odd and even pages)

The page number, as can be seen in the code (relevant part adapted from here), needs to be inside the darker rectangle, outside of the text block.

\documentclass[twoside]{scrartcl}
\usepackage[papersize={216mm,280mm},
inner=22mm,
outer=26mm,
footskip=11mm,
top=24mm,
bottom=23mm,
footnotesep=4mm,
columnsep=6mm,
]{geometry}

\usepackage{xcolor}

\usepackage{lipsum,blindtext}

footsepline=true,plainfootsepline]
{scrlayer-scrpage}

\clearpairofpagestyles %use after defining page style

\lefoot*{Some very very long name}
\rofoot*{Some very very long name}
\setkomafont{pagenumber}{\sffamily}

\DeclareNewLayer[
background,
oddpage,
align=tr,
hoffset=\paperwidth,
voffset=0pt,%distance from top
%width=1cm,% width of the swatch
width=\paperwidth,
contents={\textcolor{lightgray!50}{\rule{9mm}{\layerheight}}
\textcolor{lightgray!70!black}{\rule{15mm}{\layerheight}} \textcolor{lightgray!50}{\rule{190mm}{\layerheight}}
}% end contents
]{swatch.odd}

\DeclareNewLayer[
clone=swatch.odd,
evenpage,
align=l,
%align=tl,
hoffset=0pt
]{swatch.even}

% add layers to every pagestyle

\begin{document}
\lipsum[1-10]
\end{document}

Any other possible or simpler solutions, e.g. with TiKz, would be most welcome, too.

But I am note sure what the desired result is. Maybe something like

Code:

\documentclass[twoside]{scrartcl}
\usepackage[papersize={216mm,280mm},
inner=22mm,
outer=26mm,
footskip=11mm,
top=24mm,
bottom=23mm,
footnotesep=4mm,
columnsep=6mm,
]{geometry}

\usepackage{xcolor}

\usepackage{lipsum}

\usepackage[footsepline=true,plainfootsepline]
\clearpairofpagestyles

\ofoot*{Some very very long name}
\setkomafont{pagenumber}{\sffamily\bfseries}

\DeclareNewLayer[
background,
topmargin,
mode=picture,
contents=\putLL{\textcolor{lightgray!50}{\rule{\layerwidth}{\layerheight}}}
]{swatch.bg}
\DeclareNewLayer[
clone=swatch.bg,
oddpage,
outermargin,
width=18mm,
contents={
\putLL{%
\textcolor{white}{\rule{1.5mm}{\layerheight}}%
\textcolor{lightgray!70!black}{\rule{15mm}{\layerheight}}%
\textcolor{white}{\rule{1.5mm}{\layerheight}}%
}
\putC{\makebox(0,0){\pagemark}}
}
]{swatch.odd}
\DeclareNewLayer[
clone=swatch.odd,
evenpage,
]{swatch.even}

\begin{document}
\lipsum[1-20]
\end{document}

Note: If the layers should be added to every page style (and not only scrheadings) as mentioned in a comment of your code then you can use

or

Update

If the pagenumber should be on the baseline of the header, I would use

\documentclass[twoside]{scrartcl}
\usepackage[papersize={216mm,280mm},
inner=22mm,
outer=26mm,
footskip=11mm,
top=24mm,
bottom=23mm,
footnotesep=4mm,
columnsep=6mm,
]{geometry}

\usepackage{xcolor}

\usepackage{lipsum}

\usepackage[footsepline=true,plainfootsepline]
\clearpairofpagestyles

\ofoot*{Some very very long name}
\setkomafont{pagenumber}{\sffamily\bfseries}

\DeclareNewLayer[
background,
topmargin,
mode=picture,
contents=\putLL{\textcolor{lightgray!50}{\rule{\layerwidth}{\layerheight}}}
]{swatch.bg}
\DeclareNewLayer[
clone=swatch.bg,
oddpage,
outermargin,
width=18mm,
\putLL{%
\textcolor{white}{\rule{1.5mm}{\layerheight}}%
\textcolor{lightgray!70!black}{\rule{15mm}{\layerheight}}%
\textcolor{white}{\rule{1.5mm}{\layerheight}}%
}
}
]{swatch.odd}
\DeclareNewLayer[
clone=swatch.odd,
evenpage,
]{swatch.even}

\begin{document}
\lipsum[1-20]
\end{document}

• That's great. If fact, it's better and cleaner than I expected. If I wanted to change \pagemark to be on the baseline of the header, what should I do? I tried changing \putC and \makebox, but to no avail.
– user9424
Mar 26, 2018 at 14:45