A smart valve is created by 4D printing of hydrogels that are both mechanically robust and thermally actuating. The printed hydrogels are made up of an interpenetrating network of alginate and poly(N-isopropylacrylamide). 4D structures are created by printing the “dynamic” hydrogel ink alongside other static materials.