I understand that using @RowStyle I can determine the style depending on specific values of a field. But how can I do it if I want to differentiate the five first records (id >= 1 and id <= 5) from the other ones?
For example, in my case an Activity entity starts with 5 activites by default. The goal is to show those first 5 rows with a different color or style and the rest of the records, added by the user, with regular style. Like this:
How can I apply the style just to the first 5 rows?

@RowStyle does not allow you to define complex logic, but just compares the value of a property. However, you can achieve it defining a calculated property where you can put that logic. Something like this:
Note the type property where we put the logic that determines the style.