You could learn your favourite songs and riffs but honestly a lot of my riffs come from jamming the theory I learn. From there comes the melody and then the motif after. Which leads right into the chord progression.
There are so many ways...I have found that when I am just playing and goofing around on the guitar, great riffs will just come. Other times, I will pick up a different guitar I own that has a totally different sound or tuning and they will come that way. I also echo listening to as much music as you can, jam along to your favorite artists and just play. When you are having fun and not thinking about writing a riff in particular, the inspiration just hits in my experience! hope that helps
Playing riffs you like to understand how they are built and knowing a little bit of theory like major and minor scale helps a lot. And listening to a lot of songs you like, repeat them, check some tabs, try to understand what's going on in the music and on the neck.