  We investigate the chiral phase transition within a sphere under a uniform
background magnetic field. The Nambu--Jona-Lasinio (NJL) model is employed and
the MIT boundary condition is imposed for the spherical confinement. Using the
wave expansion method, the diagonalizable Hamiltonian and energy spectrum are
derived for the system. By solving the gap equation in the NJL model, the
influence of magnetic field on quark matter in a sphere is studied. It is found
that inverse magnetic catalysis occurs at small radii, while magnetic catalysis
occurs at large radii. Additionally, both magnetic catalysis and inverse
magnetic catalysis are observed at the intermediate radii ($R\approx4$ fm).
