There are sleeper compartments on the SJ Night trains – I took one to Malmö, but they also run to the north and across to Göteborg.
https://www.sj.se/en/about/about-sj/our-trains/sj-night-trai...
https://www.sj.se/en/about/about-sj/our-trains/sj-night-trai...
I took the sleeper from Stockholm to Kiruna in Lapland not too long ago. Definitely takes a while but it was a really nice experience!