You need to check the ‘capacity’ and ‘maximum sprocket’ from the Shimano website and then compare with your proposed setup. Capacity is the front teeth difference (yours is 16) plus rear difference (e.g. A 12-26 would be 14). If you are at or under the spec all will be well, if it’s over it may not be possible to set the chain length so all gears can be used. You also shouldn’t exceed the max sprocket spec (it’s probably 28T), as the mech may hit the sprocket.
Neither of these values are absolute and in the case of capacity you can always set the chain length based on the big to big combination and accept that some small to small gears shouldn’t be used.
My understanding is that a 10 speed cassette will fit an 8 speed hub, but my experience only goes as far as 9 speed.