Reactive power sharing and voltage containment for inverter-based resources (IBRs) are two important but related objectives in inverter-based grids. In this paper, we propose a distributed control technique to achieve these objectives simultaneously. Our controller consists of two components: a purely local nonlinear integral controller that adjusts the IBR voltage setpoint, and a distributed primal-dual optimizer that coordinates reactive power sharing among the IBRs using neighbor-toneighbor communication. The controller prioritizes the voltage containment objective over reactive power sharing at all times; except for the IBRs with saturated voltages, it provides reactive power sharing among all IBRs. Considering the voltage saturation and the coupling between voltage and angle dynamics, a formal closed-loop stability analysis based on singular perturbation theory is provided, which provides practical tuning guidance for the overall control system. To validate the effectiveness of the proposed controller for different case studies, we apply it to a lowvoltage microgrid, the modified CIGRE medium-voltage network benchmark, and the IEEE 33 bus radial distribution system, all simulated in the MATLAB/Simulink environment.