The Gemara establishes that one who chops beets into small pieces on Shabbat is liable for the prohibited labor of grinding (Shabbat 74b), and the Rambam (Mishneh Torah, Shabbat 8:15) codifies that cutting detached vegetables is a derivative of grinding, while the Rambam (Mishneh Torah, Shabbat 7:5) explains the underlying principle: grinding takes one body and divides it into many smaller parts, and any action resembling this is a derivative of that labor.
The Rishonim dispute how broadly this prohibition extends: the Tosafot, as cited by the Beit Yosef (Orach Chayim 321:9), hold that the grinding prohibition applies specifically to beets and not to other vegetables, whereas the Rambam and Rashi apply it to all vegetables, and the Tur (Orach Chayim 321) rules simply that it is forbidden to cut vegetables very finely because this resembles grinding.
The Ben Ish Hai (Halachot 2nd Year, Mishpatim 1–19) rules stringently that all produce grown from the ground — fruits and vegetables alike — carries the prohibition of grinding when cut finely, and Rav Mordechai Eliyahu (Maamar Mordechai Hilchot Shabbat, Chelek 4 99:19) notes that the Shulchan Arukh's unqualified language — "one who cuts vegetables finely is liable for grinding" — aligns with the stringent view, applying even to vegetables one intends to eat raw.
The key leniency accepted by many authorities turns on immediate use: Rav Mordechai Eliyahu (Maamar Mordechai Hilchot Shabbat, Chelek 4 99:22) cites the Rema's ruling that all this applies only when one cuts and sets aside, but if one cuts in order to eat immediately, it is permitted — just as the prohibition of selecting does not apply when one selects immediately for eating — based on the Rashba and the Ran.
The Mishnah Berurah (321:44) explains that the prohibition of grinding does not apply to knife-cutting at all when done for immediate eating, since the Torah did not forbid a person from eating food in large or small pieces — that is simply his manner of eating — and adds that cutting vegetables very finely for animals to eat immediately is likewise permitted; nonetheless, he notes in the following paragraph (Mishnah Berurah 321:45) that some authorities question this leniency, and the Beit Yosef advises cutting into somewhat larger pieces even for immediate use, a position several later authorities commend as the proper practice, though those who cut onions and radishes very finely need not be rebuked.
Rav Eliezer Melamed (Peninei Halakhah, Shabbat 12:2) synthesizes the dispute: because the disagreement concerns a potential Torah prohibition, one should be stringent and not cut vegetables into very small pieces for salad, but if the salad is being prepared immediately before the meal, even the stringent authorities permit it, since in that case the cutting is done in the manner of eating rather than in the manner of labor.
Rav Mordechai Eliyahu (Maamar Mordechai Hilchot Shabbat, Chelek 4 99:4) rules in practice that even those who follow the lenient view — permitting fine cutting for immediate use — should still cut into pieces that are somewhat large and should do so close to the meal, within an hour, and Rav Mordechai Eliyahu (Maamar Mordechai Hilchot Shabbat, Chelek 1 8:52) advises that one who wishes to eat finely cut salad should ideally prepare it from Erev Shabbat to avoid the question entirely.
The Arukh HaShulchan (Orach Chaim 321:6) offers a distinction based on customary practice: the grinding prohibition attaches only to those vegetables whose normal manner of preparation involves fine cutting — such as onions and garlic — whereas vegetables not ordinarily cut finely, and fruits generally, do not carry the prohibition, though he acknowledges that according to Rashi and the Rambam the prohibition applies to all vegetables.
B'Mareh HaBazak (Volume VII 42:5) rules that according to the majority of poskim it is permitted on Shabbat to cut salad vegetables into thin pieces close to the meal, though there are those who forbid it, and that accordingly one may use a household device designed for cutting salad — though some later authorities are stringent to forbid cutting vegetables with any such device.
Revavos Ephraim (Revavos Ephraim 8:159) rules that cutting vegetables thinly on Shabbat is permitted when done immediately for use, whether by hand or with a knife, and cites the Rashba's position that fine cutting of vegetables for immediate consumption is permitted, comparing it to the permitted act of separating food for immediate eating; however, preparing food for an entire week using a special vessel is forbidden.
The Debrecener Rav (Be'er Moshe 8:131) notes that the Mechaber ruled vegetables may be cut only without significant alteration, while others cited a view permitting fine cutting on the grounds that it disperses the vegetable's flavor, and he regards the matter as requiring further investigation.