A standard mantel is at least 12 inches above the height of the fireplace, if the fireplace is designed to burn wood. Six inches of clearance on either side of the fireplace opening is also standard. The brick or stone of the fireplace fills those distances for purposes of safety.
Building codes vary from municipality to municipality, but in general, they require a distance between where the wood burns and other wood surfaces. If the firebox opening measures 36 inches square, starting 6 inches above the floor, then the mantel height would be at least 54 inches above the floor, and the mantel opening would be at least 48 inches across, incorporating a minimum of 6 inches on each side.
One obstacle that many homeowners face when installing a new mantel is narrow wall space above the fireplace. In some cases, a full mantel shelf is wider than the fireplace wall permits. One rule of thumb is to double the firebox width to get the ideal width of the mantel shelf. In the example of the 36-inch-wide firebox, the mantel shelf would run at least 72 inches. If slightly less is available, the shelf should still work aesthetically, but another decorative option would likely be better if the wall is significantly narrower than the recommended width.