We present a phase field approach to wetting problems, related to the minimization of capillary energy. We discuss in detail both the Γ-convergence results on which our numerical algorithm are based, and numerical implementation. Two possible choices of boundary conditions, needed to recover Young's law for the contact angle, are presented. We also consider an extension of the classical theory of capillarity, in which the introduction of a dissipation mechanism can explain and predict the hysteresis of the contact angle. We illustrate the performance of the model by reproducing numerically a broad spectrum of experimental results: advancing and receding drops, drops on inclined planes and superhydrophobic surfaces.