If it is on the long wall of the closet all you need is a free 36 of space in front of it 30 in chicago no clothes in the closet for both scenarios.
Electrical panel box in closet.
The wording is vague as it does not absolutely prohibit a panel in a closet more like just around easily ignited materials.
The short safest and most efficient answer to this question is yes.
With the electrical panel installed on the narrow side wall there might not be required 30 space unless you have a deep clothes closet.
Nema 3r if exposed to weather.
These codes cover the installation and placement of residential circuit breaker boxes including main service panels and subpanels.
In summary electrical panels can be located anywhere other than in bathrooms clothes closets above steps of a stairway or in fire rated partitions or area separation walls as long as the proper working clearances are provided per nec 110 26 and the enclosure type is suitable for the application i e.
According to section 240 24 d of the national electrical code nec which says overcurrent devices shall not be located in the vicinity of easily ignitable material such as in clothes closets you are not permitted to do this.
If clearance was kept i don t see a major issue as pictured.
Nec 240 24d overcurrent devices shall not be located in the vicinity of easily ignitable materials such as a clothes closet.
This section does not differentiate between one type of clothes closet or another.
However there are a few issues to consider a bout the language of this code and how it applies to your specific situation.
Panels are located in utility closets and approved all the time with proper clearances.