Is there a diagonal-striped `warning’ border in LaTeX/TikZ

bordertikz-pgf

I'm not sure what this type of border is called but you may have seen one before in the manual of a power tool or kitchen appliance. See this Breville product recall webpage for an example: https://www.breville.com/us/en/support/Recall.html

It seems like it would be straightforward to make a diagonal striped border with TikZ: (1) make a rectangle filled with diagonal stripes of alternating color; (2) blank a slightly smaller rectangle in the center; and (3) apply to the page directly or as an image file (e.g. How do I add beautiful borders to the title page or Create page border using tikz). I was wondering if this type of border already exists in a package?

Best Answer

This can be easily done with tcolorbox, but also with a TiKZ filled with a pattern and a centered label to whiten the text background. Here you have both solutions:

\documentclass{article}
\usepackage[most]{tcolorbox}
\usetikzlibrary{patterns.meta}
\usepackage{lipsum}

\newtcolorbox{mybox}{enhanced, sharp corners, boxrule=5mm, 
    frame style={pattern={Lines[angle=45, line width=3mm, distance=6mm]}, 
    pattern color=red}, colback=white}
        
\newtcbox{mytcbox}[1][]{enhanced, sharp corners, boxrule=3mm, 
    frame style={pattern={Lines[angle=45, line width=2mm, distance=3mm]}, 
    pattern color=red}, colback=white, fontupper=\Large\bfseries\sffamily}


\begin{document}
\begin{mybox}
\lipsum[1]
\end{mybox}

\mytcbox{Alert!!!}

\noindent\begin{tikzpicture}
\node[minimum width=3cm, minimum height=2.5cm,
    pattern={Lines[angle=45, line width=2mm, distance=3mm]}, pattern color=red, 
    label={[fill=white, minimum width=2.5cm, minimum height=2cm, 
             font=\Large\bfseries\sffamily]center:Alert!!!}]{};
\end{tikzpicture}


\end{document}

enter image description here

Related Question