A man is bound to his neighbor in two ways: justice and charity. Justice is concerned with giving what is right to whom it is owed (S.T. II-II q57 a1). Charity is the action whereby a man wills the good of another for the sake of God. St. Thomas says the charity we give to our neighbor is the same action as loving God, since a man cannot love God and hate his brother (S.T. II-II q25 a1, cf. I Jn. 4:20).
Therefore, under the aspect of justice, our neighbor is owed some share in the material goods that are superfluous to us by the virtue of distributive justice, as I have discussed elsewhere. Our neighbor has a right to sufficient material goods for himself and his family. Therefore, the virtue of justice compels a man to give what he can for the sake of his neighbor.
On the other hand, the virtue of charity causes a man to act for the good of his neighbor without concern for rights. In this sense, charity may cause a man to give to his neighbor beyond what is his right, solely for the reason that his needs can be met by an act of charity.