Problem with inventory categories

I’ve been working on a inventory system for my game and recently I have run into a problem.

I want to be able to add an item into the inventory and have it sorted into a category based on type.
Then, if a row in a category is full, the category would scale and push everything down to make more room.

Example:

Now the issue is when I go to onto mobile, the slots keep their scaling.

Now I’ve already tried switching from offset to scaling. But when I scale the category, it moves the slots further away from each other.

Example:

I know Pet Simulator 99 does this. And I want to achieve the same effect.

Here is my current layout:
image

Any help help on how I could achieve this effect would be great!
Thanks!

  • Mattc04