President Reagan's coattails stretched deeper into the heart of Texas than anywhere else in the country this week, reviving Republican hopes of becoming a legitimate grass-roots party here and leaving Democrats to ponder how best to stay afloat in the tricky cross-currents of demographic change.

The Republican rout was thorough. Reagan carried Texas by 1.5 million votes (64 to 36 percent); Rep. Phil Gramm (R) trounced liberal state Sen. Lloyd Doggett (D) by nearly 900,000 votes (59 to 41 percent) in a U.S. Senate race that was supposed to be tight; the GOP picked up four U.S. House seats, 16 state House seats (upping its total to a record 53 of 150 in that chamber) and dozens of local judgeships.

"There was a tremendous amount of straight-party Republican voting," said Jan van Lohizen, a Houston-based pollster who works with V. Lance Tarrance.

"What we are seeing is the beginning of a realignment in the political pattern of Texas," said state GOP Chairman George Strake.

Republicans were saying much the same thing in 1978, when blue-collar and white-collar workers drawn here by the oil boom helped elect the century's first Republican governor, William Clements.

But when Clements lost his bid for reelection in 1982, the race seemed to turn on the flip side of those demographic changes: blacks and especially browns had also been flocking to Texas in vast numbers. Using sophisticated get-out-the-vote techniques that have become a model for the national party, state Democratic operatives did such a good job of registering and turning out minorities in 1982 that Clements, even though he received more votes than in 1978, lost decisively to Mark White.

Since 1982, Democratic policies in this state have taken a liberal cast -- though the preferred word here is "progressive." White came from the Tory wing of his party, but several unapologetic liberals were elected to statewide office along with him, and White this year pushed through a tax increase to raise teachers' salaries and to increase equalization funding for low-income school districts.

The ascendancy of the Democratic Party's liberal wing was ratified this spring when Doggett won a razor-thin victory in a bitter primary race for the open Senate seat over his fellow Democrat but ideological opposite, Rep. Kent Hance.

In the wake of Tuesday's bloody result, moderate and conservative Democrats point fingers at Doggett. "Our party suffered one of its worst defeats of this century, and a lot of the blood is on Lloyd Doggett's hands," said Democratic pollster George Shipley.

"The corrosive effect of having both Doggett and Mondale at the top of the ticket put the Democrats further down the ballot right on the firing line," he added. "They had no buffer."

White, while not naming Doggett, appeared to share the judgment. "If there had been a Lloyd Bensten or someone of that sort at the senatorial level as an incumbent, I think you would have found that to be the stopping point on the ballot," he said.

Shipley and others said one lesson is that "a liberal Denocratic Party cannot prevail in the Sun Belt." The party's problem is that with minorities an ever more important part of the demographic mix here, liberals will continue to be competitive, if not dominant, in party primaries.

Republicans, meanwhile, hope they can leave the other party stranded by appealing to disenchanted conservative Democrats. "We have become the party of growth and opportunity here," Strake said. "We've made big headway with the rural voters who used to automatically pull the Democratic lever, with Hispanics, and with young people. And we do very well with the new Texans, who don't have the 'Daddy was a Democrat' hangup."

Strake and other GOP leaders acknowledge that it is too early to predict, on the basis of one election dominated by a popular incumbent president, whether the GOP can turn Texas into a full-fledged two-party state. But he notes slow but steady GOP gains at the local level for two decades -- already enough to make it clear that Texas is different from the Deep South states, which are such a wasteland for grass-roots Republicans.

It is possible, van Lohizen said, that the state will follow more of a California model and undergo "dealignment" rather than realignment, with its voting patterns at all levels characterized by weak party identification and constant ticket-splitting.