A buttonhole looks like the fiddly part of a shirt, and on an old machine it was. You stitched one bead, pivoted, stitched back and guessed at the length. Any machine built in the last twenty years does the lot in one pass, and the foot sizes the hole off the button you are using.
Sewing Parts Online walks through it on a Brother in under five minutes. The part people miss is not the stitching. It is a small lever behind the needle bar that nobody notices until the buttonhole comes out wrong.
What you need
An automatic buttonhole foot: the long clear one with a sliding tray at the back. It probably came in the accessory box with your machine. Replacements are sold by brand and shank type, so match it to your make.
Past that: the button itself, thread that matches the fabric, a seam ripper, and a scrap to test on. Interfacing or tear-away stabilizer is optional on quilting cotton and close to mandatory on anything thin or stretchy. Get the machine threaded and drop in a full bobbin first. A buttonhole eats thread, and running out mid-bead means unpicking the lot.
The button goes in the foot, not on the fabric
That sliding tray at the back of the foot is a measuring jig. Clamp your button into it and the machine reads the length and stitches a hole to match. Big button, long buttonhole. Small button, short one. You never type in a number.
Use the button off the garment, or one from the same card. A near-enough button is how you end up with a hole a shank button will not pass through.
The lever is the step people skip
Behind the needle bar sits a lever that pulls straight down. Pull it as far as it goes, then push it back so it rests behind the white tab on top of the foot. That is what tells the foot when to turn around and come back.
Leave it up and the machine stitches one side of a buttonhole until you stop it. A long bead with no bar tacks is the lever, every time.
Where the buttonhole sits on the garment
The foot stitches away from you and comes back, so put the needle at the front end of the hole. On a shirt placket that means measuring down from the collar and dropping the needle at the top of each mark.
Sew a test hole on a scrap of the same fabric, same layers, same interfacing. Two minutes of testing saves the shirt. New to the machine? The machine basics walkthrough covers stitch selection and foot pressure.
Buttonholes on knits and thin fabric
Knit stretches under the foot and the bead comes out wavy. Two fixes, and they stack. Double the fabric or back it with stabilizer, then swap to a topstitch needle so the thread has a bigger eye to travel through. Embroidery thread lays down a denser bead that hides a lot.
Woven fabric rarely needs that. If it frays badly, a square of fusible interfacing behind the buttonhole stops the cut edges unraveling six washes later.
Cutting it open without wrecking it
Seam ripper, not scissors. Come in at one bar tack, run toward the middle, then do the same from the other end. Stick a pin across the hole just inside each bar tack first and a ripper that skids hits the pin instead of your stitching.
Common buttonhole problems and fixes
Thin, gappy bead: shorten the stitch length, or slow down so the fabric feeds evenly. Puckering: foot pressure is too high, or the piece wants stabilizer. Second hole a different size from the first: the size memory reset when the lever got lifted, so run a whole row before you touch anything. Stitches a little then stops dead: the tray is not pushed back against the button.
Once the holes are cut, sew the buttons on by hand, positioning each against the finished buttonhole rather than the original mark. Buttonholes are handy with no button in sight, too: run a drawstring or a ribbon through one and you have a tidy casing opening, the same job a zipper does the hard way.