PCB enclosures for Arduino, ESP32, Raspberry Pi and custom boards

Snap-fit vs screws vs magnets in 2026: how to close a 3D printed enclosure

Five ways to close a 3D printed box: screws, snap-fit, magnets, a sliding lid and a friction lid. What each asks of the design and the print, and its prompt.
17 November 2026 · 7 min readenclosureslidsfit

Choose the closure by how often the box is opened. Screws for a box that must stay shut and is opened rarely; a snap-fit lid for one opened now and then, with no hardware; magnets for one opened every day; a sliding lid for a battery compartment; a friction lid for a prototype. Each asks something different of the design, the material and the print, and each fails in its own way.

The short answer

  • Stays shut, opened rarely, or lives outdoors: screws. The only closure that can squeeze a gasket.
  • Opened now and then, no hardware: snap-fit. Print it in PETG.
  • Opened every day, by hand: magnets. Nothing wears, but a knock can open it.
  • A battery door, or a box you reach into often: a sliding lid.
  • A prototype, or a box that only keeps dust out: a friction lid. The simplest to design.

Side by side

ClosureOpensYou addThe number that mattersGoes wrong when
ScrewsWith a screwdriverScrews, plus inserts or nuts if it opens oftenFor M3: 3.4 mm in the lid, 2.5 mm in the pillarThe thread cut in the plastic strips
Snap-fitBy hand, now and thenNothing0.2 mm of interference, an arm 6 times its thicknessAn arm snaps at its root
MagnetsBy hand, dailyMagnets and a drop of glueA 6 mm magnet in a 6.2 mm pocketA magnet is glued the wrong way round
Sliding lidBy hand, oftenNothing0.4 to 0.6 mm in the groovesThe lid's first layer bulges and jams
Friction lidBy handNothing0.2 to 0.3 mm around the lipIt loosens, or pops off in a fall

Clearances are per side and come from the tolerances guide.

Screws: for a box that must stay shut

The design. A pillar in each corner of the base with a hole for the screw, and a matching hole in the lid. For an M3 screw that cuts its own thread, the pillar hole is 2.5 mm. In the lid the screw slides through a 3.4 mm hole, and a flat head sinks into a 6.6 mm countersink, a cone only 1.6 mm deep. A socket head needs a counterbore 3.4 mm deep with 2 mm of plastic under it, which is too much for a thin lid. Countersink or counterbore has the other sizes.

The material and the print. Any filament, though PETG and ABS hold a thread cut by the screw better than PLA. Print 3 walls or more, so the screw bites into solid plastic.

How often. A thread cut in plastic survives a handful of openings. A box opened regularly wants metal for the screw to turn in: a heat-set insert or a nut in a hexagonal pocket.

What goes wrong. Overtightening strips the thread, and a pillar that is too thin splits along its layers.

In SpeakCAD. All of it is hand work: Hole with its Screw head choice for the lid, Add for the pillars, Hole with the tap toggle in each pillar, Duplicate for the other three corners. Or say "lid screwed with four M3 screws into corner pillars". Outdoors, add a groove for a 2 mm O-ring; the outdoor sensor enclosure has its numbers.

Look elsewhere if the box opens every day: nobody keeps a screwdriver next to a remote control.

Snap-fit: no hardware, opened now and then

The design. A cantilever clip is a small arm with a hook at its end. It bends as the lid goes on and springs back behind a ledge. Give the hook 0.2 mm of interference and a 45° lead-in, make the arm at least 6 times as long as it is thick, put a small fillet at its root, and keep the lid at 1.6 mm or more so the clips have something to pull against. Between the lid and the box, leave 0.2 to 0.3 mm.

The material and the print. PETG or nylon flexes without cracking. PLA is stiff and brittle: fine for a lid opened a few times, wrong for one opened every week. An arm is strongest printed lying flat, so that it bends along its layers. On a lid printed flat the arms stand up and bend across them, the weak way, which is why the bend has to stay small and the arm long. Use 3 walls or more and 0.16 to 0.20 mm layers.

How often. Now and then. Every opening bends the plastic, and clips relax with heat: snap fits creep in the sun.

What goes wrong. An arm too short to bend, so the lid will not close; an arm that snaps at a sharp root; a hook with too much interference. A five-minute test slice of the rim finds the right number before the long print.

In SpeakCAD. A snap-fit hook is not a hand tool. Say "snap-fit lid" and the AI builds the clips and reports the interference it used.

Look elsewhere if the box sits in a car or in the sun, or if one broken clip would mean reprinting a six-hour base.

Magnets: for a lid opened every day

The design. Pairs of small disc magnets, one in the lid and one in the base, in pockets that face each other. A 6 mm magnet presses into a 6.2 mm pocket with a 0.3 mm chamfer at the mouth; make the pocket 0.2 mm deeper than the magnet so it sits just below the surface. A pocket needs plastic around it, so it goes in a corner pillar about 10 mm across, not in a 2 mm wall. Magnets do not stop a lid sliding sideways: add a lip that drops inside the box with 0.3 mm of clearance.

The material and the print. Any filament. Put the pockets on faces that print facing up. Press the magnets in cold, with a drop of glue: heat weakens them, so a soldering iron is the wrong tool.

How often. As often as you like. Nothing bends and nothing wears.

What goes wrong. Polarity. Let each pair snap together first, mark the two outer faces with a pen, and only then glue. A magnet without glue ends up stuck to its partner, out of its pocket. Keep magnets away from a compass sensor or a reed switch on the board inside.

In SpeakCAD. A magnet pocket is a hand tool: Cut, a circle 6.2 mm across and 2.2 mm deep for a 6 × 2 mm magnet, placed by its distances from the edges, then Duplicate.

Look elsewhere if the box travels in a bag, where a knock opens it, or if it has to seal.

The two simple ones: a sliding lid and a friction lid

A sliding lid is a flat plate that runs in two grooves along the top of the long walls. Leave 0.4 to 0.6 mm in the grooves, chamfer the lid's bottom edge by 0.5 mm against the bulge of the first layer, and ask for a thumb grip and a small bump that clicks at the end of its travel. It opens as often as you like, which is why battery compartments use it. The grooves are AI work: say "sliding lid in side grooves", and ask for their upper side at 45° so they print without sagging. Look elsewhere if the lid is long and thin, because it bows, or if the box has to seal.

A friction lid has a lip that pushes into the box, 0.2 to 0.3 mm smaller per side than the opening, with a 0.5 mm chamfer to find its way in. It is the quickest closure to shape by hand: a plate the size of the box, then Add a rectangle on its underside as the plug. To the AI: "friction lid with a 0.3 mm lip". Look elsewhere if the box is carried around: a friction lid loosens with use and pops off in a fall.

Mix them

The best lids often use two. A lip for alignment plus two magnets. A sliding lid plus one screw for transport. Two fixed tabs along one edge and a single snap on the other, which halves the clips that can break.

For a circuit board, the enclosure generator and the PCB enclosure guide start from the board's own measurements, and the lid is one phrase in the description.

Shaping a part by hand (a hole, a cut, an added shape, text, rounded corners, a shell, every size typed in millimetres) is free, and so is downloading what you shaped. With the AI, a request spends credits for the work it takes: a quick edit usually 1–2, a small change 1–2, a new part or a design change 3–8, never more than 15 credits; on a plan the first 3 small changes of each part are free; without a plan a new part spends 3. Start with Maker: 50 credits a month for $7.99, cancel anytime.

Prompts to start from

Open one in the builder, change the numbers to yours, and the model renders in your browser, usually within a minute or two. Keep adjusting in the chat before you print.

A two-part enclosure for a 70 x 50 mm PCB with 3 mm holes 4 mm from each corner, 20 mm internal height, 2 mm walls, a 3 mm lid screwed with four M3 countersunk screws into corner pillars with 2.5 mm holes the screws cut their own thread in

Open in the builderPre-filled after sign-in. Try it in the live demo first, no account needed.

A box 90 x 60 x 35 mm outside with 2 mm walls and a snap-fit lid 1.6 mm thick: two cantilever clips on each long side, 0.2 mm interference, 45 degree lead-in, 0.3 mm clearance between lid and box

Open in the builderPre-filled after sign-in. Try it in the live demo first, no account needed.

A box 100 x 70 x 40 mm outside with 2.4 mm walls, a lid with a 2 mm lip that drops inside with 0.3 mm clearance, held by four 6 x 2 mm magnets in pockets 6.2 mm across and 2.2 mm deep in 10 mm corner pillars

Open in the builderPre-filled after sign-in. Try it in the live demo first, no account needed.

Questions

It depends on how often it opens. Screws for a box that must stay shut, is opened rarely or lives outdoors; a snap-fit lid in PETG for one opened now and then with no hardware; magnets for one opened every day; a sliding lid for a battery compartment; a friction lid for a prototype.

Give each clip 0.2 mm of interference and a 45° lead-in, make the arm at least 6 times as long as it is thick, put a small fillet at its root, and print in PETG with 3 walls or more. An arm bends best along its layers, so keep the bend small when the arms print standing up. Test the fit on a five-minute slice of the rim before the full print.

0.2 mm larger than the magnet for a press fit: a 6.2 mm pocket for a 6 mm magnet, with a 0.3 mm chamfer at the mouth and 0.2 mm of extra depth so the magnet sits just below the surface. Check the polarity of each pair before gluing, and press magnets in cold, because heat weakens them.

Yes, for a joint opened a few times. Make the hole smaller than the screw so it cuts its own thread: 2.5 mm for M3, 3.3 mm for M4. Print 3 walls or more, and prefer PETG or ABS, which hold the thread better than PLA. For a lid opened often, use a heat-set insert or a nut in a hexagonal pocket.

0.4 to 0.6 mm per side in the grooves, plus a 0.5 mm chamfer on the lid's bottom edge so the bulge of the first layer does not jam it. Print the lid flat and the base open side up.

Generate the enclosure for your board

Describe the board, the ports and how the lid closes. The case renders in your browser and every cutout is a sentence away from moving. Turning it around in 3D and typing a new number are free; a request spends credits for the work it takes: a quick edit usually 1–2, a small change 1–2, a new part or a design change 3–8, never more than 15 credits; on a plan the first 3 small changes of each part are free.