Guidelines

Main site

Typography Colour system Iconography Imagery Content Layout & spacing Actions and input Mobile applications Accessibility
Home Design guidelines Layout & spacing

Layout & spacing

A space’s structural set-up is key to a clean design and great user experience. Layout determines how all the elements of a page support consistency across the website by defining grids, spacing, and sections.

Responsive design

The design system has six breakpoints, based on common screen resolutions. Each breakpoint is a minimum width: styles prefixed with it apply from that width and up.

BreakpointMinimum widthCSS

xs

480 px

@media (min-width: 480px) { ... }

sm

640 px

@media (min-width: 640px) { ... }

md

768 px

@media (min-width: 768px) { ... }

lg

1024 px

@media (min-width: 1024px) { ... }

xl

1280 px

@media (min-width: 1280px) { ... }

2xl

1536 px

@media (min-width: 1536px) { ... }

The xs breakpoint is added by the design system; the others are the Tailwind CSS defaults. Learn more about responsive design in Tailwind CSS.

Understanding the breakpoints helps you understand the grid, because the grid reacts to them and lets you change the number of columns at each breakpoint.

The approach to mobile responsive design

Since the arrival of smartphones, websites that adapt to the screen size of the device have become essential. Media queries were first proposed in 1994, the W3C began work on them in 2000, and the rapid growth of smartphones and touch devices led to Media Queries becoming a W3C Recommendation in 2012.

Today it is hard to imagine a website without media queries. In 2020, Google announced that mobile-first indexing would become the primary way Google Search indexes websites.

Why is this important?

The design system takes a mobile-first approach in its CSS. When you design and build the front end of your website, start with the layout for a mobile device, and then gradually add the changes needed for larger screens.

How to create mobile-first responsive layouts

Start by designing and writing code that works on the smallest screen. Then add conditional styles for what changes as the screen gets larger. As the design system is built on Tailwind CSS, you can learn more from its guide to working mobile-first.

Tailwind CSS: Responsive design, using responsive utility variants to build adaptive user interfaces

In practice, unprefixed utilities (such as uppercase) apply to all screen sizes, while prefixed utilities (such as md:uppercase) apply only from that breakpoint and up. To target mobile, use the unprefixed utility, not sm:.

<!-- One column on mobile, two from md, three from lg -->
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 md:gap-6">
  ...
</div>

<!-- Centred text on mobile, aligned to the start from md -->
<h2 class="text-center md:text-start">Our services</h2>

The importance of a mobile-first approach

A common school of thought is to let analytics decide: the share of traffic from each type of device defines the approach. However, for consistent and usable design that stands the test of time, it is prudent never to ignore mobile devices and small screens when designing and building interfaces for websites and services.

What about larger screens?

Responsive design is not only about small screens. To be truly responsive, the design and development team must also consider how the website looks on large screens. The sections below explain containers, grids and the default sizes, and the design system can be extended for larger screens when required by adding breakpoint variants.

Containers

Containers are the most basic layout elements. They limit the width of the content and keep it aligned and centred on the page. The design system provides the aegov-container class, which adds the correct side padding at each breakpoint and centres the content up to a maximum width of 1536 px.

Before using a container, keep the following in mind:

.aegov-container
<header>
content-area
content-area
<footer>
Do not wrap the entire website in a single container
<header> .aegov-container
content-area .aegov-container
content-area .aegov-container
<footer> .aegov-container
Use a container inside each full-width section

A <div> with the container class must not be the main wrapper of your whole website. Instead, give each broad section of the page its own container. This lets a section, for example one with a background image, stretch across the full width of the screen, while its content stays aligned with the content of the other sections.

Container padding at each breakpoint

The container is fluid: it takes the full width of the screen, minus the side padding, until it reaches its maximum width of 1536 px. From then on, it stays centred with an inner content width of 1488 px.

24
2xl (1536 px and up): max 1488 px, centred
24
24
lg and xl (1024 px and up): 100% − 48 px
24
14
md (768 px and up): 100% − 28 px
14
20
sm (640 px and up): 100% − 40 px
20
12
Below 640 px: 100% − 24 px
12
Screen widthSide paddingInner content width

Below 640 px

12 px (px-3)

100% − 24 px

640 px (sm)

20 px (sm:px-5)

100% − 40 px

768 px (md)

14 px (md:px-3.5)

100% − 28 px

1024 px (lg) and 1280 px (xl)

24 px (lg:px-6)

100% − 48 px

1536 px (2xl) and up

24 px

1488 px, centred

<!-- A full-width section with its content aligned in a container -->
<section class="bg-primary-50 py-12 lg:py-20">
  <div class="aegov-container">
    <h2>Our services</h2>
    ...
  </div>
</section>

Why is the container fluid on mobile?

Below the large breakpoints, the container uses the full width of the device, minus the side padding. Mobile devices come in many screen sizes and can be held in portrait or landscape orientation, so a fluid layout adapts content and elements to any screen.

The design system provides templates as a guide to responsive layouts. When you design the layout of a specific page, consider all the device sizes your users may use: design mobile first, starting at 320 px, and keep the layout fluid as the screen grows.

Full-width sections

A section can span the full width of the screen, ignoring the container, for example a hero section with a full-screen background image. Keep the text and actions inside an aegov-container within that section, so that they stay aligned with the rest of the page.

Do not make the content of the entire website full width. On large screens of 2,500 px or more, lines of text become too long to read and the layout loses its intended look. A full-width approach is acceptable for campaign websites, creative landing pages, initiative microsites or graphics-led websites, but only with responsive typography for large screens; it is not recommended for corporate websites.

Grid

A grid lets designers and developers align content vertically and horizontally, and it continues to evolve with design trends. The design system follows the Tailwind CSS approach, in which:

  • column widths are calculated as percentages rather than fixed widths;
  • the space between columns (the gutter or gap) is set separately, with gap utilities;
  • columns are created with CSS Grid or Flexbox, without a separate row class.

The following shows the column widths available in the design system, adapted from Tailwind CSS.

Grid widths from w-1/6 (16.667%) to w-full (100%), including sixths, fifths, quarters, halves and thirds

The 6-column approach

In a 6-column layout, each column is one sixth (1/6) of the container, so column widths come in multiples of 16.667%. The example below uses CSS Grid, changes the number of columns at each breakpoint and adds a 24px gap (gap-6) between the columns.

With CSS Grid

1/6
16.667%
1/6
16.667%
1/6
16.667%
1/6
16.667%
1/6
16.667%
1/6
16.667%
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-6 gap-6">
  <div>1/6</div>
  <div>1/6</div>
  <div>1/6</div>
  <div>1/6</div>
  <div>1/6</div>
  <div>1/6</div>
</div>

You can combine columns so that an item spans from one to five of them. See the example below, and grid column start and end in Tailwind CSS.

1/6
16.667%
2/6
33.333%
3/6
50%
<div class="grid grid-cols-1 lg:grid-cols-6 gap-6">
  <div>1/6</div>
  <div class="lg:col-span-2">2/6</div>
  <div class="lg:col-span-3">3/6</div>
</div>

With Flexbox

The same 6-column layout can be built with Flexbox, where you control the width of each item at each breakpoint, or switch Flexbox off on certain screen sizes. Percentage widths already add up to 100%, so add a gutter with padding inside each item rather than a gap, which would push the items onto a new line. When you need gutters, CSS Grid is usually simpler.

1/6
16.667%
1/6
16.667%
1/6
16.667%
1/6
16.667%
1/6
16.667%
1/6
16.667%
<div class="block lg:flex lg:flex-wrap">
  <div class="w-full lg:w-2/6 xl:w-1/6">1/6</div>
  <div class="w-full lg:w-2/6 xl:w-1/6">1/6</div>
  <div class="w-full lg:w-2/6 xl:w-1/6">1/6</div>
  <div class="w-full lg:w-2/6 xl:w-1/6">1/6</div>
  <div class="w-full lg:w-2/6 xl:w-1/6">1/6</div>
  <div class="w-full lg:w-2/6 xl:w-1/6">1/6</div>
</div>

Use width utilities flexibly to create 4-column or 3-column layouts:

  • The 4-column approach creates columns of 25% each, combined in multiples of 25%. It is useful for horizontal rows of four items.
  • The 3-column approach creates columns of 33.333% each.

What about the traditional 12-column grid?

The 12-column grid (1/12) was the backbone of consistent web design for many years. Designers now mostly use sixths, quarters and thirds, which give more realistic column widths. A 12-column grid can still be useful on large screens, for example when a sidebar needs less emphasis than the content area and 2/6 is too wide while 1/6 is too narrow. Tailwind CSS supports 12 columns as well; use them only when needed.

<!-- A narrow sidebar (2/12) and a wide content area (10/12) on large screens -->
<div class="grid grid-cols-1 xl:grid-cols-12 gap-6">
  <aside class="xl:col-span-2">Sidebar</aside>
  <main class="xl:col-span-10">Content</main>
</div>

Grid with spacing

Columns do not add space around themselves by default. Traditional grids forced a gutter between columns, whereas modern web design may also place elements with no space between them.

Use gutters when content needs to be visually separated, such as a set of news cards on a homepage. Set the gutter on each grid with the gap utilities; see gap in Tailwind CSS.

The design system recommends a 24px gutter (gap-6) on large screens. On smaller screens, adjust the gap to what looks best, for example 16px (gap-4).

<!-- Four news cards: 16px gutter on mobile, 24px from lg -->
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 lg:gap-6">
  <aegov-card>...</aegov-card>
  <aegov-card>...</aegov-card>
  <aegov-card>...</aegov-card>
  <aegov-card>...</aegov-card>
</div>

Spacing

Spacing is an important, and often overlooked, part of a design system, and it must be used intelligently. When designers talk about making a website "breathe", they are talking about spacing.

Use the scale

Whether linear or modular, adopt one standard scale. Tailwind CSS includes a comprehensive numeric spacing scale.

Spacing units

Use standard spacing units instead of arbitrary values, tied to the baseline and the size of the text.

Responsive adjustment

Adjust spacing as the screen size changes, including the margins around the content area.

Visual balance

Mathematical consistency matters, but so does visual balance. Always review the design to make sure it feels right.

Spacing is not only about putting space between elements; used strategically, it creates clearer, more intuitive interfaces. As with any design rule, understand the reasoning behind it, because there will always be exceptions based on context.

The spacing scale

One spacing unit is 0.25rem (4 px). Use increments of 2px up to the base font size of 16px (1rem), and increments of 4px from there up to 48px. Larger spacing, used between sections, continues in bigger steps.

Keep spacing proportional: 16px is twice as much spacing as 8px, for example.

The Tailwind CSS spacing scale, from px (1 px) and 0.5 (2 px) to 40 (160 px), with each value in rem and pixels

UseSuggested spacingExample classes

Between an icon and its text

8 px

gap-2

Padding inside components, such as cards

16–24 px

p-4, lg:p-6

Gutters between grid items

16–24 px

gap-4, lg:gap-6

Space between blocks of content

32–48 px

mb-8, lg:mb-12

Space between page sections

48–96 px

py-12, lg:py-20, 2xl:py-24

Layouts in both directions

UAE government websites are published in Arabic (right to left) and English (left to right). Build layouts with logical properties, which follow the reading direction, so that one layout works in both languages:

  • Use ms-, me-, ps-, pe-, start- and end- instead of ml-, mr-, pl-, pr-, left- and right-.
  • Use text-start and text-end instead of text-left and text-right.
  • Grid and Flexbox already follow the reading direction, so columns reverse automatically on Arabic pages.
  • Use the rtl: and ltr: variants only for the rare cases that logical properties cannot cover, such as mirroring a directional icon.
<div class="ps-6 border-s-4 text-start">
  ...
</div>
Logical properties follow the reading direction
<div class="pl-6 border-l-4 text-left">
  ...
</div>
Physical properties stay on the left in Arabic