San Francisco Bay area officials unveiled Monday what might be the most aggressive and restrictive measures in the country yet to curb the spread of the coronavirus.

Northern California officials announced a "shelter in place" order that will affect nearly 7 million residents of six counties in the Bay Area as the region tries to contain the COVID-19 outbreak.

The order asks all residents of six Bay Area counties, including San Francisco, Santa Clara, San Mateo, Marin, Contra Costa and Alameda, to remain home as much as possible. It takes effect at midnight and will last until April 7, the order says.

"We know these measures will significantly disrupt people's day-to-day lives, but they are absolutely necessary," San Francisco Mayor London Breed said. "This is going to be a defining moment for our city and we all have a responsibility to do our part to protect our neighbors and slow the spread of this virus by staying at home unless it is absolutely essential to go outside."

Residents can leave their homes under "limited circumstances," according to the order. At such times, people are expected to remain six feet apart, wash their hands, cover their coughs or sneezes and abide by a number of other requirements.

"You will still be able to walk your dog or go on a hike alone, or with someone you live with, or even with another person as long as you keep six feet between you," San Francisco health officer Dr. Grant Colfax said at a news briefing.

While the order will shutter businesses across the region, officials emphasized that essential businesses like grocery stores and pharmacies will remain in operation and that the order will not strictly confine people to their homes. Officials added that restaurants will remain open for delivery and takeout.

Colfax added that anyone who leaves the county while the order is in place, except for essential travel, "would be out of compliance coming back."

"We're going to take a compassionate, common-sense approach," Chief of San Francisco police William Scott said. "We're asking the public to voluntarily comply. Now, this order by law is enforceable as a misdemeanor, or failure to comply with it, but that is an absolute last resort."

San Francisco reported 40 confirmed COVID-19 cases as of Monday morning, according to the county's department of health. Neighboring Santa Clara and San Mateo counties have reported 114 and 41 confirmed cases, respectively. In total, the Bay Area's collective confirmed cases is more than half of California's total case count, the counties said in a statement.

Across California, there are more than 470 confirmed cases, according to Johns Hopkins University.

"While the goal is to limit groups congregating together in a way that could further spread the virus, it is not complete social shut down," Dr. Matt Willis, Marin County's Public Health Officer, said in a statement. "You can still complete your most essential outings or even engage in outdoor activity, so long as you avoid close contact."

COVID-19 has infected more than 4,200 people across the country, according to Johns Hopkins' data, and killed at least 74 people. Nearly half of all confirmed cases in the country are concentrated in three particularly hard-hit states: Washington, California and New York.

The order comes after a number of states announced harsh social distancing measures meant to curb the spread of the virus. The governors of New York, New Jersey and Connecticut, citing "a lack of federal direction and nationwide standards," announced Monday they have agreed to jointly reduce density throughout the region, closing movie theaters and limiting public gatherings to fewer than 50 people.

Maryland Gov. Larry Hogan announced similar measures later Monday calling the step "unprecedented." Separately, Washington Gov. Jay Inslee said Monday he signed an emergency declaration temporarily shutting down bars, restaurants and other places of recreation statewide. He also banned public gatherings of more than 50 people.

"Never since World War II have we faced a situation like this," Inslee said. "For the next several weeks, normal is not in our game plan."

Read CNBC's live updates to see the latest news on the COVID-19 outbreak.