From https://support.apple.com/en-us/HT201834 Published Date: Jun 6,
2017
...
You can use an external display or projector with a Mac notebook while
its built-in display is closed. This is known as closed-clamshell or
closed-display mode.
Requirements for closed-display mode
To use closed-display mode with your Mac notebook, you need:
- An AC power adapter
- An external keyboard and mouse or trackpad, either USB or wireless
- A USB-C to USB adapter if you're using a USB mouse or keyboard with MacBook (2015 and later) or MacBook Pro (2016 and later)
- An external display or projector
Enable closed-display mode
Use these steps to enable closed-display mode. If the external display
isn't recognized when it's connected and your Mac is powered on, try
connecting the display while your computer is asleep or off. Then wake
or turn on the computer after you connect the display.
If you're using a USB keyboard and mouse
- Make sure that your Mac notebook is plugged in to an outlet using the AC power adapter.
- Connect a USB keyboard and mouse to your Mac.
- With your Mac turned on and the display open, connect the Mac to the appropriate port on the external display or projector and turn the
display or projector on. Use an appropriate Apple video adapter if
necessary.
- After your Mac notebook's Desktop appears on the external display, close the computer's lid.
- When you close the lid:
- In OS X Lion 10.7 and later, the external display changes to a blue screen, then shows your Desktop.
- In OS X 10.6.8 Snow Leopard and earlier, you can wake your Mac by clicking the mouse button or pressing a key on the external keyboard.
You can now use your Mac notebook as you normally would with a USB
keyboard and mouse.
If you're using a wireless keyboard and mouse
- Make sure that your Mac notebook is plugged in to an outlet using the AC power adapter.
- Verify that Bluetooth is turned on in the Bluetooth pane of System Preferences or the Bluetooth menu icon Bluetooth icon.
- Pair your Bluetooth keyboard or mouse with your Mac.
- In the Bluetooth pane of System Preferences, click Advanced and make sure the checkbox next to Allow Bluetooth devices to wake this
computer is selected.
- With your Mac turned on and the display open, connect the Mac to the appropriate port on the external display or projector and turn the
display or projector on. Use an appropriate Apple video adapter if
necessary.
- After your Mac notebook's Desktop appears on the external display, close the computer's lid.
- When you close the lid:
- In OS X Lion 10.7 and later, the external display changes to a blue screen, then shows your desktop.
- In OS X Snow Leopard 10.6.8 and earlier, you can wake your Mac by clicking the mouse button or pressing a key on the external keyboard.
You can now use your Mac notebook as you normally would with a
wireless keyboard and mouse.
Disconnect your Mac notebook from the display after use
It's best to put your Mac to sleep by choosing Apple menu > Sleep
before disconnecting your display.
Some DVI and Mini DisplayPort displays — including Apple's
aluminum-framed DVI displays and the 24-inch and 27-inch LED Cinema
Displays — can be unplugged without putting the computer to sleep. If
you aren't sure whether your display supports this feature, put your
computer to sleep before unplugging the display.
Opening the internal display while in closed-display mode
Opening the display on your Mac notebook while it's in closed-display
mode will have different results based on the operating system you're
using.
OS X Lion 10.7 and later If you open the lid of your supported Mac
notebook computer running OS X Lion 10.7 and later while in
closed-display mode, the display flickers to a blue screen after a few
moments, and then both displays become active. Close the lid to return
to closed-display mode.
OS X Snow Leopard 10.6.8 and earlier If you open the lid of your
supported Mac notebook computer running OS X Snow Leopard 10.6.8 and
earlier while in closed-display mode, it might appear to have no
video. This is expected behavior. When your computer is in
closed-display mode, the built-in display is disabled and all video
memory is allocated to the external display. To reactivate your
built-in display, put the computer to sleep and then wake it, or use
the Detect Displays button in the Displays pane of System Preferences.
You can also press Command-F1 on keyboards that don't have a Numlock
key.