How many tandem or mini breakers can you install in a panel?
Whatever the panelboard label says, and nothing more. The NEC does not give a number. Section 408.36 covers overcurrent protection of the panelboard itself, and the old 42 circuit limit was deleted from the code in the 2008 edition. What replaced it is 110.3(B), which requires listed equipment to be installed in accordance with the instructions included in the listing. Those instructions are printed on the circuit directory label inside the door.
Reading the label
A typical residential label reads something like "Max 30 spaces, 40 circuits" or "20 spaces / 20 circuits". The first number is the physical mounting positions. The second is the maximum number of overcurrent devices the panel is listed to hold. If spaces and circuits are the same number, the panel accepts no tandems at all. If circuits exceed spaces, the difference tells you how many tandem positions exist.
Manufacturers also restrict where those tandems go. Many panels accept tandems only in the bottom four or six positions, and the bus stabs in those positions are physically notched to reject a tandem elsewhere. That rejection feature is the CTL, or circuit total limiting, provision from the UL 67 panelboard standard. Filing the notch or forcing a breaker into a non-CTL position defeats a safety listing and is a direct 110.3(B) violation.
Classified breakers
Some brands sell breakers listed as "classified" for use in other manufacturers panels. They physically fit and they carry a UL classification, but the panel manufacturer typically states in its own listing that only its breakers are acceptable. Since 110.3(B) points to the panelboard instructions and 408.54 states a panelboard shall not have installed more overcurrent devices than the number for which it is designed, rated, and approved, most inspectors reject classified breakers in a panel whose label names a specific breaker family. Ask your AHJ before you buy a box of them.
The rules that still apply after you fit them
Section 408.54 is the hard stop on device count. Section 408.36 requires each panelboard to be protected by an overcurrent device having a rating not greater than that of the panelboard, with the exceptions for a panelboard used as service equipment. Multiwire branch circuits under 210.4(B) require a means to simultaneously disconnect all ungrounded conductors, and a tandem breaker with two independent handles does not satisfy that, so a shared neutral circuit needs a two pole breaker or handle ties on adjacent single poles sharing a stab pair.
Watch AFCI and GFCI requirements too. Section 210.12(A) requires arc fault protection for most 120 volt 15 and 20 ampere dwelling circuits, and tandem AFCI and dual function breakers exist but not for every panel and not in every position. Confirm availability before you plan a panel around 40 circuits.
Field takeaway
Open the door and read the label. Spaces versus circuits tells you the tandem allowance, and the notched stabs tell you where they go. When the panel is genuinely full, a subpanel is cheaper and safer than crowding devices the enclosure was never listed to hold.