The Onsager principle is a fundamental law for irreversible processes in statistic physics. It has been used to develop theoretical models for many problems in soft matter, like the diffusion process, the dynamics of liquid crystal solution and the moving contact line problems, etc. Recently, the variational principle has been used as an approximation tool to derive reduced models for many complicated systems. In this talk, we will present some applications the Onsager variational principle in numerical analysis, including derivation of a moving finite element method for gradient flows and geometric partial differential equations, etc. In particular, we will show that the variational formulation makes it convenient to design physics preserving numerical schemes and to do numerical analysis.