The mood varies over the course of "The Gift of the Magi," from tragic to lighthearted, and from anxious to affectionate.
At the beginning of the story, as Della considers her limited options for buying Jim a present, the mood is somber:
Della finished her cry and attended to her cheeks with the powder rag. She stood by the window and looked out dully at a grey cat walking a grey fence in a grey backyard. To-morrow would be Christmas Day, and she had only $1.87 with which to buy Jim a present.
The sensory details match Della's sadness—her "dull" gaze takes in an uninspiring backyard scene, featuring unvaryingly "grey" objects. These details add to the sense that Della is trapped in bleak circumstances that are unlikely to change, and the reader is meant to sympathize with her in this regard.
This bleak mood persists as Della is preparing to go out and sell her hair:
Once she faltered for a minute and stood still while a tear or two splashed on the worn red carpet. On went her old brown jacket; on went her old brown hat.
The "worn" carpet and the repetition of "old brown" in describing Della's clothes reinforce the point that Della is poor and hasn't been able to afford nicer things for a long time, hence the need to go to the extreme of selling her hair. Her lingering tears splashing the frayed carpet add to the tragic feel.
However, once Della sells her hair and hurries off to buy Jim's gift with the $20 she's earned, the mood shifts significantly to hopeful excitement:
"Give it to me quick," said Della.
Oh, and the next two hours tripped by on rosy wings.
Della's love for Jim shines through in that she doesn't waste time brooding over the loss of her hair, but joyfully runs off to find the perfect present. The phrase "tripped by on rosy wings" almost satires the era's sentimental romantic poetry, but it also highlights Della's eagerness and delight, contrasting with the grey inertia at the beginning of the story. While the story's early descriptions encouraged the reader to sympathize with Della, now it encourages them to share in her excitement.
However, this feverish joy subsides into tension later as Della waits for Jim to get home:
Then she heard his step on the stair[.] [...] [A]nd now she whispered: 'Please, God, make him think I am still pretty.'
The sound of Jim gradually climbing the apartment stairs, as well as Della's plaintive prayer, cause the mood of tension to mount. For the moment, the Christmas gift fades into the background as attention shifts to Della's fear that, along with her hair, she might have sacrificed her husband's affection.
At first, Jim's reaction makes Della's fear seem plausible:
Jim stopped inside the door, as immovable as a setter at the scent of quail. His eyes were fixed upon Della, and there was an expression in them that she could not read, and it terrified her.
This is the first time Jim has appeared in the story, so the fact that his reaction is unreadable to Della makes the tension even more pronounced. The comparison of Jim to a hunting dog fixed on its prey is a bit uncanny and adds to Della (and the reader's) uncertainty about the impact of Della's actions on their marriage. It's only relieved when, moments later, Jim "enfolds" Della and assures her that nothing she does to her hair could make him love her less.
This peak of tension also sets up the anticlimactic ending. Jim's odd reaction is explained when he gives Della the beautiful hair combs he's bought her—combs she can no longer use:
But she hugged them to her bosom, and at length she was able to look up with dim eyes and a smile and say: 'My hair grows so fast, Jim!'
Della is obviously sad that she can't use the combs—it takes her a moment to collect herself, and she's teary-eyed. But she smiles at Jim and consoles him, showing that their love for each other is more important than material gifts.
This fact is reinforced by Jim's reaction to Della's gift of the watch chain. He responds by flopping on the couch and giving an ironic reply:
"Dell," said he, "let's put our Christmas presents away and keep 'em a while. They're too nice to use just at present. [...] And now suppose you put the chops on."
Instead of lamenting that he can't use the watch chain or even directly consoling his wife, Jim jokes that the gifts are "too nice" for right now. He means that the gifts are useless for the time being, so they might as well keep them out of sight and turn their attention to more immediate things.
After the dramatic emotions surrounding Della's efforts to buy the watch chain, the conclusion is an emotional letdown. Notably, too, Della's reaction isn't shown. Judging from her highly strung emotions earlier, it's realistic to suppose that she wept all over again. But by ending with Jim's philosophical reaction and appeal to homey comforts—"now suppose you put the chops on"—the story suggests that the couple's strong marriage will endure, and that they'll continue to find joy in the everyday pleasures of life together. The story's mood thus leaves the reader with an overall sense of optimism despite the emotional roller coaster that they've endured alongside Della and Jim.