A compass is a small case of glass. A magnetised needle is pivoted inside the box. The needle can rotate freely. Compass also has a dial with directions marked on it. The compass is kept at the place where we want to know the directions. When the needle comes to rest it indicates north-south direction. The compass is then rotated until the north and south marked on the dial are at the two ends of the needle.
Usually different colours are used to point the ends of needle to identify the north and the south poles.