Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add guidance for break-word override class #3968

Merged
merged 1 commit into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }) }}