As an alternative to placing in the functions.php file, I trust you could load these from a custom plugin that you could make yourself so that your chosen patterns would be independent of the theme.

I tried out the sample code you posted and while it rendered, the styling as a bit off. The buttons were not correct. Perhaps WordPress 5.4 is required?