While creating or editing a product you can add variants such as size or color. When a buyer picks a combination in the shop, the system resolves the matching variant, and availability and price depend on that variant.
Full details in the documentation: Add Products.
