There are several ways:
The most basic and fundamental one is based on series LC circuit with high Q factor: Harmonic trap. The circuit resonates at a specific harmonic frequency and is essentially a short circuit in this specific frequency.
More advanced technique is based on switched LC filter. I recommend looking at ABB's Static VAR compensator as an example.
APF is based on the traditional bridge-rectifier circuit, with boost converter.
The switch on/off signal is modulated to create a semi-sinus current waveform, with a high frequency component (at least 50 kHz) in phase with the line voltage.
This method creates DC output, and must include an EMI/RFI filter at its input.
Filter selection is difficult because there is no single solution. Usually, there are many possible solutions (type/location ect.), and the designer must select the one that is the most suitable solution based on specific objectives to meet standards, design criteria, specifications and power system. In industrial systems, multiple single-tuned filters are the most common solutions. However, there may be other types of filters as included in IEEE s guidelines. Refer to IEEE P1531, IEEE 519 and IEEE 399 (chapter 10) to get an understanding for the procedure of selection applicable to filters and regulation of reactive power.