You need gaps if you sort alphabetically. I did tricks over the years to keep em upright.
I inherited LPs that came with true library shelving with recessed metal tracks and dividers, Expensive, doubtful I would ever have spent that much but it’s the best/easiest system I ever had. My friend had found a library selling it’s shelving.
Actually, I kept only the individual shelves with integral backs/tracks/dividers, and put them on rolling steel shelving, not attractive, but in the garage.