# Access value of colframe in custom drawing for tcolorbox

I am trying to make a tcolorbox that uses custom code to draw its frame but which accesses the color stored in colframe.

So far I have tried

\newtcolorbox{leftborderbox}[1][]{
enhanced,
breakable,
colframe=orange,
colback=orange!20,
frame code={
\fill[fill=\pgfkeysvalueof{/tcb/colframe}] (frame.south west) -- (interior.south west) -- (interior.north west) -- (frame.north west);
},
sharp corners,
boxsep=0pt,
left=5pt,
right=5pt,
top=6pt,
bottom=6pt,
boxrule=0pt,
leftrule=4pt,
#1
}

\begin{leftborderbox}[colframe=pink]
Hi There!
\end{leftborderbox}


but I get an error about \pgfkeysvalueof{/tcb/colframe} not being a color. How do I access the value of this key?

Some of the colours being specified to the tcolorbox options are available with a prefix tcbcol@, e.g.

• tcbcol@frame for the colour of the frame
• tcbcol@title -- title text colour
• tcbcol@back -- background colour
• tcbcol@upper -- upper box text colour
• tcbcol@lower -- lower box text colour
• tcbcol@backtitle -- background colour of title

In the default \tcbset setting in tcolorbox.sty those tcbcol@... are actually statements for .colorlet:

\tcbset{... % excerpt from tcolorbox.sty

colback/.colorlet=tcbcol@back,
colframe/.colorlet=tcbcol@frame,
colupper/.colorlet=tcbcol@upper,
collower/.colorlet=tcbcol@lower,
coltext/.style={colupper=#1,collower=#1},
coltitle/.colorlet=tcbcol@title,
...
}


\documentclass{article}

\usepackage[most]{tcolorbox}

\newtcolorbox{leftborderbox}[1][]{
enhanced,
breakable,
colframe=orange,
colback=orange!20,
frame code={
\fill[fill=tcbcol@frame] (frame.south west) -- (interior.south west) -- (interior.north west) -- (frame.north west);
\draw (0,0) node {};
},
sharp corners,
boxsep=0pt,
left=5pt,
right=5pt,
top=6pt,
bottom=6pt,
boxrule=0pt,
leftrule=4pt,
#1
}

\begin{document}

\begin{leftborderbox}[colframe=pink]
Hi There!
\end{leftborderbox}
\end{document}


• This is perfect! Is there any way to access the .colorlet attribute so I don't need to dig into the internals of tcolorbox? – Jason Siefken Jun 15 '17 at 21:12
• @JasonSiefken: You're welcome. Sometimes, it's necessary to look into package codes to get the relevant information. I had to so recently quite a lot concerning the colour settings of tcolorbox, so I remembered this – user31729 Jun 15 '17 at 21:14
• @JasonSiefken: I know of no such way but this doesn't mean there's none – user31729 Jun 15 '17 at 21:22