We thought Gen X was a bunch of slackers. Now they’re the suits.

The Great Ideological Wars of 2017 have pitted gray-hairs against snowflakes, the we-liked-it-the-old-way boomers, more than half of whom cast their ballots for Donald Trump, vs. the idealistic millennials, who would prefer it if Grandpa kept his paws off their rights.

Then there’s the wild card: The 66 million aging hipsters known as Generation X.

Their very name conjures images of underemployed slackers, of flannels and Kurt Cobain and Elizabeth Wurtzel, the medicated and nihilistic symbol of the Prozac Nation. (This is assuming that anyone thinks of Gen X, so clearly America’s neglected middle child, at all.)

After college, Gen X donned flannel and started bands called Soundgarden and the Smashing Pumpkins. When a recession in 1990 and ’91 — no, millennials, yours was not the only recession — drained the nation of hope and career prospects, Gen X got a menial job and aspired to nothing much at all. By the late 1990s, the Atlantic had fretted that this sea of 20- and early-30-somethings had chosen “political apathy as a way of life.”

But as it reaches 50, Gen X no longer looks like an extra from “Reality Bites.”

Gen X looks like Paul Ryan.

Consider the conservatives who barnstormed the last election cycle: There is the new U.S. ambassador to the United Nations, Nikki Haley, who’s 45; Sen. Ted Cruz, 46; and Wisconsin Gov. Scott Walker, 49.

“A typical Generation Xer” is how presidential counselor Kellyanne Conway, who at 50 is on the very fringes of Xer-dom, described herself in an interview with The Washington Post this year.

White House press secretary Sean Spicer? Generation X. (He’s 45.) At 36, senior adviser Jared Kushner may be, too, depending on which of the many generational parameters you subscribe to.

If you didn’t realize that Sen. Marco Rubio is Gen X, surely it dawned on you last week, when the 45-year-old met a constituent’s request for a town hall with a classic Gen X response — a shrugging “I don’t know, man . . .”

If they were angry and disillusioned teenagers in the 1980s and ’90s, in middle age they are “very naturally libertarian, very pragmatic,” says Neil Howe, co-author of “13th Gen: Abort, Retry, Ignore, Fail?,” the 1993 book that defined the generation. During Gen X’s formative years, Americans were embracing individualism, the free marketplace and unabashed capitalism.

“Gen X is a perfect reflection of that: ‘No one is going to help you. No handouts. It’s up to you,’ ” Howe says. “Particularly first-wave Xers, they’re just naturally Republican.”

Generations are defined in part by birth year, in part by psychology. With Generation X, it’s that middle-child thing.

The Census Bureau defines boomers as those born between 1946 and 1964, and millennials as the 83 million Americans born between 1982 and 2000. Gen X has been harder to pin down; the Census Bureau draws the lines at those born between 1968 and 1979 but says nothing about the three years between the end of the baby boom or the three before the millennials’ arrival.

“The boomers were a very noisy generation from the get-go, a very navel-gazing generation, and the millennials have also been a noisy generation, in part because of their size,” Taylor says.

That’s not the case with Gen X.

Gen X marked a nadir for the American birthrate. Families were fracturing, divorce was reaching its peak, and children, left to their own devices, were becoming “latchkey kids.” Widespread adoption of the pill made childbearing a choice, but there was also a “cultural aversion to children,” Howe says. It was apparent from the movies of the era, including “The Omen” and “Rosemary’s Baby.” The Zero Population Growth movement had taken hold. Women were flooding the workplace.

In the young Gen Xer, the culture of the era “instilled a wariness and skepticism, and a kind of ‘figure it out for yourself’ mind-set,” Taylor says. And with that came a sense “that you don’t have to shine a light on yourself. You’re not the center of the universe.”

‘Powerhouses of industry’

For a brief moment, however, X was in the spotlight. Pop culture was enchanted with the Xers and their unwashed icons, including Cobain. The author and artist Douglas Coupland gave the disenchanted youth their name in his 1991 novel “Generation X: Tales for an Accelerated Culture.” The movies “Slacker,” “Reality Bites” and “Singles” made the long-haired and angst-ridden persona an archetype.

Were Xers ever really slackers? The recession of the ’90s proved a blip. “What they’ve done is grown into people who’ve become powerhouses of industry,” says Anna Sofia Martin, author of “Gen X @ 50,” a recent report from cultural forecast firm Sparks & Honey. Elon Musk is an Xer, as are the founders of Google. Studies show that they’re not only facile at technology but also equally capable of turning it off.

“You have a generation, mostly in their 40s, who have begun to achieve national prominence,” Taylor says.

The boomers are creaking off the stage. Forecasts suggest that by the next election, they’ll no longer make up the majority of voters. Donald Trump may well be the last boomer president.

And then, Gen X will take up the slack.

Correction: An earlier version of this article incorrectly identified “Rosemary’s Baby,” which was released in 1968, as a movie from the 1970s. This version has been updated.

Lavanya RamanathanLavanya Ramanathan is a features reporter covering youth, culture and trends for Style. She worked as an editor and reporter at Newsday and the Orlando Sentinel before coming to The Post in 2004. Follow