US President Donald Trump has toured the US border with Mexico and examined eight styles of walls, prototypes for the barrier he promised to build to keep out illegal immigrants and drugs.

The Republican president brought a tough message on immigration to California during his first visit as president to the heavily Democratic state that has served as a base of resistance to many of his policies.

Standing beside the prototypes, as US border patrol agents rode nearby on horseback, Trump discussed the merits of various designs with border officials, his chief of staff John Kelly and Homeland Security Secretary Kirstjen Nielsen.

“The border wall is truly our first line of defence,” Trump told reporters.

Trump has asked the US Congress for $US18 billion to build the structure, but the funding has become ensnared in controversy over a host of immigration restrictions he and Republicans have proposed.

On the other side of the border, in Tijuana, Mexico, residents laughed off the idea that the monolithic slabs will stop desperate immigrants.

“The wall is just a waste of money. People will continue to cross, here, there, and everywhere,” said Salome Pacheco.

During his visit, Trump took aim at so-called “sanctuary cities” in California – local governments that refuse to cooperate with federal immigration officials seeking to deport illegal immigrants.

He renewed complaints that Los Angeles, San Francisco and other major cities are providing protection for illegal immigrants who have committed crimes.

Last week, Trump’s Justice Department filed a lawsuit accusing California of violating the US Constitution and putting federal agents in danger by approving laws protecting illegal immigrants.

California Democratic Governor Jerry Brown signed a bill into law last October that prevents police from inquiring about immigration status and curtails law enforcement cooperation with immigration officers.

Brown, who accuses the Trump administration of waging war on the country’s most populous state, has said the law was crafted with input and support from California police.

Trump also slammed Brown for high state taxes, saying Brown “has done a very poor job running California.”

After his San Diego stop, Trump will travel to Los Angeles to headline a political fundraiser in Beverly Hills.

A Republican Party official said the fundraiser would net $US5 million for Trump’s prospective 2020 re-election campaign and the Republican National Committee.

By Steve Holland