Living systems are essentially out of equilibrium, where concentration gradients are kinetically controlled by reaction networks that provide spatial recognitions for biological functions. They have inspired life-like systems using supramolecular dynamic materials and systems chemistry. Upon pursuing ever more complex life-inspired systems, mimicking the ability to learn would be of great interest to be implemented in artificial materials. We demonstrate a soft hydrogel model system that is programmed to algorithmically mimic some of the basic aspects of classical Pavlovian conditioning, the simplest form of learning, driven by the coupling between chemical and physical processes. The gel can learn to respond to a new, originally neutral, stimulus upon classical conditioning with an unconditioned stimulus. Further subtle aspects of Pavlovian conditioning, such as forgetting and spontaneous recovery of memory, are also achieved by driving the system out-of-equilibrium. The present concept demonstrates a new approach towards dynamic functional materials with “life-like” properties.