Lil Nas X wrote the song with producers Take A Daytrip, Roy Lenzo, and Omer Fedi, the same team behind his previous single, "MONTERO (Call Me By Your Name)
." Both tracks are about Nas X's identity as a homosexual. However, while "Montero" is a sexually explicit song about a gay dalliance, "Sun" is more contemplative. The producers' slow-whining acoustic guitar, understated trap beats and strings give the track a melancholic feel.