WASHINGTON — On the night in April 2015 that Baltimore went up in flames, Carla D. Hayden, the city’s chief librarian, was under pressure to board up a neighborhood library branch and wait out the violence triggered by the death of Freddie Gray after being injured in police custody.

But she had other ideas.

“I thought, what would that show?” Dr. Hayden said. “That we’re afraid?”

Instead, as a CVS drugstore across the street was looted and burned, and as the governor of Maryland declared a state of emergency, Dr. Hayden and her staff decided they would open their doors the next morning, welcoming in the weary public.

For Dr. Hayden, who was sworn in on Wednesday as the 14th librarian of Congress, the unrest was the test that clarified her values: Libraries are about far more than books.

“The people of that neighborhood protected that library,” Dr. Hayden said during a recent interview in her new office overlooking Capitol Hill. “There were young men who stood outside. It was such a symbol.”