If you've got a bedroom with no closet, it's likely that the bedroom lacks space overall, so do some math to decide if you have the room for a closet plus the other furnishings needed in a bedroom. If you find the space too cramped, you can always put in a portable unit that can be moved out of the way at need. Recommended closet depth is 24 inches. The width of the closet is subject to how much room you can afford to part with. The height is typically 84 inches for the upper shelf, while the closet walls typically extend to the room's ceiling.
Studs and Drywall Versus Plywood
Two basic options typify closet-building techniques: Build a closet with studs and drywall, or assemble a free-standing closet with plywood. Also know as an armoire, or a wardrobe, the plywood closet is typically a better choice than studs and drywall. It's cheaper, easier to build, and it's movable. Studs and drywall consume 6 or 7 cubic feet of space. An armoire takes up a minimum of limited space.
Build a Permanent Closet with Studs
Measure the desired width of the closet. Cut two two-by-fours at that length with a miter saw. These are for the horizontal plates that run at the top and bottom of the front wall.
Make a mark, 24 inches (or as desired) from the wall, on the ceiling for the depth of the closet. Run a stud finder along the ceiling to locate the ceiling joists. If the joists are perpendicular to the depth of the closet, mark each joist inside the closet. If they're parallel, mark the joist closest to 24 inches. You will fasten the wall's top plate into the ceiling joist(s).
Make additional marks at 24 inches on the ceiling, then draw a line for the top plate, making sure it's parallel with the back wall. Use a plumb bob to plumb down from the top plate line, transferring the layout to the floor to mark the position of the bottom plate. This ensures that the top and bottom plates are perfectly aligned with each other.
Screw the top plate to the ceiling joist or joists with a drill/driver and 3-inch screws. Place the bottom plate on the wood subfloor. Screw the plate to the floor with 3-inch screws. If you need to enclose either end of the closet, cut and install short top and bottom plates that extend from the front plates to the room wall. These should be perpendicular to the front plates.
Measure the vertical distance between the top and bottom plates. Cut two-by-four studs to the measurement; you'll need one for each wall corner and one for each end that butts into the room's walls. You can also add an additional stud for a heavy-duty corner. Toe-nail the studs to the plates with 3-inch screws at the corners.
Toe-nail two vertical studs with screws in the top and bottom plates to begin framing the door opening on the front of the closet. Position each stud 1 1/2 inches to the outside of the planned door opening. These are called the king studs, and together with the jack studs added next, they form the interior ends of the return walls.
Cut two more studs at 82 inches -- recommended -- or the height you desire; these are the jack studs. Screw them to the inside faces of the king studs. Measure the distance horizontally across the tops of the jack studs. Cut a two-by-four to this length; this is the header of the door opening. Screw the header to the tops of the jack studs. Cut away the section of the bottom plate inside the door opening (between the jack studs), using a reciprocating saw.
Measure, cut and toe-nail additional studs with screws, to fill in the walls, using 16-inch on-center spacing (16 inches between stud centers). Add horizontal two-by-four blocks centered at a height of 80 inches, or place a vertical studs centered on the 24-inch walls to support the ends of the closet rod.
Measure and cut sections of drywall as needed with a utility knife. Screw them to the walls on both sides with 1 1/4-inch drywall screws. Finish the drywall with tape and drywall compound as needed. Optionally, trim the door opening with lumber.
Measure and cut a 1 1/4-inch closet rod to the inside width of the closet. Use 1 1/4-inch pipe flanges and 1 1/4-inch screws to install the closet rod centered at a height of 80 inches.
Install bifold or other type of closet doors using the hardware and instructions provided. For bifold doors, install the jamb brackets on the floor first. Install wheels and pins on the bifold sections, followed by the track on the header. Hang the doors on the track.