From rut to rally.

The ETF that tracks retail's biggest names, the XRT, is up almost 4% for June, putting it on course for its best month since February. On Monday the XRT gained about 1%, lifted by names like Walmart, Dollar General and Costco, all of which hit multiyear highs.

Retail's June swing follows an abysmal May in which the ETF posted its worst month in more than a decade after shedding roughly 13%. Two experts say these stocks are now back in style, although they say investors should pick individual names rather than buying the space as a whole.

From a thematic perspective Oppenheimer's Ari Wald likes "higher-growth" companies like Costco, while on a technical basis he says turnaround names like Wayfair look attractive.

"What we like about it [Wayfair] is it has corrected since March," he said Monday on CNBC's "Trading Nation." "It's worked off those previously overbought conditions and now it's turning up from an important support level at $138," he noted after examining the charts, adding "we think this is a resumption of the stock's long-term uptrend."

Shares of the Boston-based company have skyrocketed 74% this year, making it the third-best performing stock in the XRT, behind Carvana and Boot Barn Holdings.

Wald cautioned against buying the space as a whole since there's a big divergence between components within the XRT.

"I think you still want to be selective, especially when you consider that the equal-weighted retail SPDR XRT is coming off its lowest relative level versus the S&P since the start of the bull market back in March of 2009," he said.

While Amazon and its e-commerce competitors may seem unstoppable, BK Asset Management's Boris Schlossberg argues that the space may actually have reached overcrowded levels, and that investors should instead focus on physical retailers and the experiential aspect of shopping they offer.

Specifically, he likes Ollie's Bargain Outlet as a long-term play, since it provides the hunt and surprise satisfaction element of in-person shopping.

"They basically have the huge advantage of surprise and discovery that's impossible to replicate in e-commerce," he said, adding that they're a "very small company" with "plenty of room to grow."

Shares of the retailer have gained about 45% this year and are sitting about 6% below last month's all-time intraday high of $103.03.

"I think the problem with e-commerce is that it's going to be this inexorable move towards efficiency, toward one-day delivery, instant gratification. That means massive infrastructure spend. Everyone's going to compete, and it's going to be more expensive for all of them," he said. "I think the e-commerce space is going to actually get ground down by competition."

Ollie's has a $6 billion market cap and is trading at 42 times forward earnings.