You can make shelves our of playing cards, if you know what you are doing.
Really, foam board is such great stuff. I have used for many purposes. So, let me teach you to fish. Then you will know how to figure out foam board structures, OK?
- span
- span end support
- rigidity placement
That is all you need to know.
Foam board at what thickness? 1 cm or 2 cm?
I treat it exactly like plywood, but, with only about 20% of the breaking strength yet with, a lot less sag for its on weight. Would you make a shelf out of 1cm plywood, 12cm wide and 2 meters long? Not a useful one.
So, plywood has little sheets glued together in what is called a structural sandwich. Very important to understand. Foam board is a structural sandwich (I hope you don't mean bare foam) The covering glued to each side, make a 3 piece foam and paper, structural sandwich.
So, the way I tackle this is to ask the question a bit differently. It is not, "will it work?"
With structures, it is "How to make it work?"
I would cut a test shelf. I would put that across a pair of chair backs and start destructive testing with my exercise weights, bags of sugar, bricks or whatever, and I would find out the load break on one layer of shelf at my design span.
If I am 50% over at least of what the design load is, I am good to go.
Else add another layer to your sandwich.
Make sure you tape layers together on the edges so you have your structure.
OK? Next one. Would you take a piece of plywood shelf and just nail into the end, thru the side panel. NO! You need a cleat for the end to rest on, yes? Weight bearing structure. Nails through foam, are not weight bearing.
So, cut 1cm x 1cm foam board strip and fix that with little nails and then tape the hell out of it to the side panel.
It is so light weight, this box you are building, you can afford to make it beefy by taping structure where you need it.
Hope it helps.