In places like Detroit racism was very much the primary reason in the 1940s, 1950s, and 1960s at least. Some of it was just personal racism, pure and simple. See "blockbusting" techniques used by realtors who would hire a black mother to walk down the street with a baby carriage to give the impetus for white people to sell quickly and cheaply. Or a black family moving into a house, the white neighbors trying to push them out via lawsuit for breaking a racially restrictive covenant, then losing so that all the white people left the neighborhood (e.g. read about Orsel and Minnie McGhee in Detroit, I was the primary author of the National Register nomination for their house).
The racist pressure to move was also a structural issue supported by the Federal government. Redlining meant you couldn't get loans to buy houses in certain neighborhoods, and those neighborhoods were exactly where black people lived. Literal walls could be constructed between two similar communities of different races so that the white side could be higher rated and have better access to loans (e.g., the Birwood Wall in Detroit). A ton has been written about the topic, I can't really do it justice, but the idea that people just wanted a bigger house was not the case. A lot of Detroit actually consisted of single-family homes with yards anyhow, so it was literally white people leaving a house for a very similar one.
I'm wondering how much of it was racism, and how much was people simply being aware that the "worse" areas of town had lots of crime (which they associated with the color of the people living there, not knowing any better) and they didn't want that crime to come to their area.
If I'm walking a street at night and I see a guy with attributes associated with poverty, I'm more likely to switch to the other side of road than if he's wearing a suit, just saying.
Racism might be part of the reason, but you have nearly entirely white cities like Portland that also experienced their own explosive suburban growth in the same time period.
Also, if "suburbanization" was really the explanation for the decline in community, you would see a clear pattern where people (regardless of race) in the suburbs have fewer friends and social lives and people in urban areas have more. But the opposite is largely true!