Hi,
This can be done with the ‘Contains shipping class’ condition. The ‘category’ condition requires all products in the cart to have the given category before the condition matches. So if there are two or more products in the cart with different categories, the rate won’t show up.
Alternatively with a custom script you can add a ‘Contains category’ condition as well that works similar as ‘Contains shippping class’.
Cheers,
Jeroen