He had support before he came to power because of his immense success as a general of the French Republic, even saving the Revolution at one point.
Howerver, becoming the sole autocratic leader of France runs against the ideas of the Revolution. What was public opinion like after his coup and onward, and how did it change from before then?
This is a broad question and I'm only going to focus upon the Brumaire coup itself and leave the Empire to others.
Napoleon was arguably the most popular general in France by the time of the Brumaire coup in 1799. He already enjoyed great fame from the Italian campaign in which his victories led him to dictate a peace treaty to Austria, but Napoleon's skillful management of public relations of his Egyptian campaign magnified his fame. Although the Egyptian campaign was in many respects a strategic disaster for France, Napoleon managed to carefully edit the news coming to France about his accomplishments. This built up Napoleon's personal mystique so much that many in France acclaimed him as a popular hero when he returned in France.
Subsequent Napoleonic mythmaking and propaganda would emphasize this popular support and present his assumption of power as a fait accompli. However, Napoleon was only one of several popular generals that various conspirators within the Directory were hoping to use to kill off the existing French government. Emmanel Sieyès, one of the key plotters in Brumaire, would famously quip, "I need a sword," in other words, a man who could command the loyalty of one of the few powerful institutions that possessed a great deal of popular legitimacy within the Republic, the army. Bernadotte, a general and Minister of War, was the favorite of the Neo-Jacobin factions that wanted to reestablish the Revolution's leveling tendencies. Jean-Baptiste Jourdan toyed around with many different factions. Lazare Hoche, who enjoyed almost as much fame as Napoleon had unfortunately died of tuberculosis before Sieyès's initial soundings towards him could bear fruit. Jean Moreau, the youngest general in the army, refused to compromise himself with politics despite entreaties to do so.
Napoleon was aware of this politicking behind the scenes and very carefully cultivated his image as an apolitical general. Aside from Napoleon's martial triumphs, which were much more prestigious than both Jourdan's and Bernadotte's, this purported apolitical character of Bonaparte put him at a more advantageous footing than his rivals. There was an apprehension amongst some of the plotters against vulgar militarism and somewhat vain generals like Bernadotte did not dissuade them of these fears. Here Napoleon's connection with Talleyrand paid dividends and the latter was able to assuage the Sieyès faction that Napoleon was an apolitical soldier concerned about the integrity of the state.
It is also important to realize the the result of the Brumaire coup, the Consulate, did not at first seem to be at odds with the precepts of the French Republic. The Consulate had a strong executive, but the First Consul in theory had checks on his power. In practice, Napoleon managed to sideline the other two Consuls very quickly and accumulated more power to the central executive. While this transition to a dictatorship put him at odds with some republicans within the state, the fact that Napoleon was able to finally introduce stability and a degree of competence within the French state allowed him to gain a great deal of popular legitimacy despite an apparent betrayal of the ideals of the Revolution. Napoleonic propaganda of the Consulate would actually accentuate the ideal that he personified the meritocratic and democratic ideals of the Revolution since he was a minor figure from the provinces that managed to rise up to the highest position in the land by virtue of talent and genius. Napoleon's victories in the field and his domestic initiatives like the Code Napoleon and the Concordat with the Papacy gave him a further patina of legitimacy that prior post-Revolutionary regimes had lacked. The Peace of Amiens in 1803 seemingly returned the continent to a period of peace that it had not known for nearly fifteen years which further added to Napoleon's popularity. The problem was Napoleon could never really make good on the promise of returning France and Europe to a state of normality and Napoleon's legitimacy became increasingly hostage to his military triumphs. Military victories began to pay less dividends within France after his invasion of Spain and sapped away at Napoleon's popularity within the country. Although he remained popular within certain French institutions like the army, Napoleon's legitimacy waned in many regions of France and led him to have a very precarious basis of popular support when military fortunes turned against him in 1813.
Sources
Dwyer, Philip G. Napoleon: The Path to Power. New Haven, CT: Yale University Press, 2008.
Woloch, Isser. Napoleon and His Collaborators: The Making of a Dictatorship. New York: W.W. Norton, 2001.