Skip to content

Commit

Permalink
Add draft guidance for break-word override class
Browse files Browse the repository at this point in the history
Co-authored-by: seaemsi <50173207+seaemsi@users.noreply.github.com>
Co-authored-by: Calvin Lau <77630796+calvin-lau-sig7@users.noreply.github.com>
  • Loading branch information
3 people committed Aug 9, 2024
1 parent d4f0a24 commit 3f941ab
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/styles/font-override-classes/break-word/index.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: Break word – Typography
layout: layout-example.njk
---

<div class="govuk-grid-row">
<div class="govuk-grid-column-one-half">
<p class="govuk-body">
<strong>With class</strong><br>
We'll send an email to: <span class="govuk-!-text-break-word">communications@llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogochuchaf.gov.uk</span>.
</p>
</div>
<div class="govuk-grid-column-one-half">
<p class="govuk-body">
<strong>With <code>wbr</code></strong><br>
We'll send an email to: <span class="govuk-!-text-break-word">communications@<wbr>llanfair<wbr>pwll<wbr>gwyngyll<wbr>gogerych<wbr>wyrndrob<wbr>wll<wbr>llanty<wbr>silio<wbr>gogogoch<wbr>uchaf<wbr>.gov.uk</span>.
</p>
</div>
</div>
16 changes: 16 additions & 0 deletions src/styles/font-override-classes/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,19 @@ Using tabular numbers can make numbers intended for comparison to one another ea
You can also use tabular numbers for numbers that dynamically update, such as in a counter. The equal width of each digit prevents the numbers from visually moving towards and away from each other as the counter updates.

Activate tabular numbers by using `govuk-!-font-tabular-numbers`.

## Breaking up long words

You might need to show long words that cannot be changed or broken into smaller parts, such as:

- technical or scientific terms
- long email addresses
- words from other languages

Long words can create issues in constrained spaces such as mobile device screens and data tables. They can 'break out' of the layout, resulting in a broken visual appearance and requiring users to scroll horizontally to view all of your content.

You can help to reduce these issues by surrounding content likely to 'break out' with `govuk-!-text-break-word`.

This class forcibly splits long words onto multiple lines when they become longer than the width of the container. It'll make the split exactly where the word would otherwise 'break out', which might make compound words more difficult to read. You can control where words can be split by inserting [the `wbr` HTML tag](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/wbr) into your content.

{{ example({ group: "styles", item: "font-override-classes", example: "break-word", html: true, open: true }) }}

0 comments on commit 3f941ab

Please sign in to comment.