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