Adsorption is a promising method to remove dyes, such as methylene blue, from wastewater. In this study, a dynamic adsorption set-up was used to treat synthetic wastewater containing methylene blue by using alkali-activated blast furnace slag and lignin composite foam. The structure of the foam without lignin was first optimized by comparing cationic and non-ionic surfactants in the preparation of the foam via the direct foaming method. The selection of the surfactant affects the porosity and pore structure of the foam through different abilities to stabilize the gas–liquid interface and changes in the viscosity of the fresh-state paste. The foam prepared with non-ionic Triton X-114 surfactant had the highest adsorption performance and was selected for the optimization of adsorption conditions. The optimized conditions were 5 mg/L influent concentration of methylene blue, pH of 7, and flow rate of 1.0 L/h (corresponding to ~ 9 min empty bed contact time). To further enhance the methylene blue adsorption performance, a composite containing lignin was prepared. The optimum lignin amount in the foam was 0.8 wt% and it resulted a ~ 93% higher adsorption amount compared to the foam without lignin. The highest cumulative adsorption capacity in this dynamic adsorption setup was 39.5 mg/g, which is among the highest reported values for methylene blue removal by monolithic adsorbents. The present study provides a proof of concept for the enhancement of adsorption performance of alkali-activated materials by introduction of lignin into the structure.