Are you looking for a circuit to be added to a pc board design, or a stand alone unit? If you think about it, any cell phone charger or other low voltage power supply is a mains detection unit.
For an on-board design or if you want to detect loss-of-mains very rapidly, that is a bit more work. For isolation, start with either a small power transformer or an optical coupler. The transformer can be either a standard small power transformer or a current transformer that has one of the mains leads fed through it. A standard transformer is larger, but the output voltage does not vary with the mains current going somewhere else.
These will give you a sine or square wave output proportional to the mains voltage or current. What happens next depends on what aspect of the mains you are testing for.
ak