Realistically, and this is a serious problem, many critical rights in the US only exist because of the court going against the voters. Like, say, the legalization of interracial marriage.
It can go both ways. For example, in 1890-1930, SCOTUS had a series of decisions that had methodically demolished the then-budging laws pertaining to labor rights and business regulations, enacted with wide popular support, on the basis that they violated "economic liberty" rights that the judges have read into the 14th Amendment use of "liberty". You know, stuff like min wage, 40-hour work week, prohibitions on child labor, mandatory qualification requirements for some professions etc.