Move classes out of the preprocess functions and into the Twig templates. Use the addClass() attribute method to add classes in the template. Use the clean_class filter to filter class names, if necessary. Maintain all existing functionality and ensure all existing class names are still in the markup, even ones that are inherited.
See the following issues for more detailed examples:
See this change record for information about using the addClass() method:
See this change record for more information about the phase 1 process of moving class from preprocess to templates:
Preprocess Functions Modified
Twig Templates Modified