---
url: "https://design-system.service.gov.uk/components/warning-text/"
titulek: "Warning text – GOV.UK Design System"
h1: "Warning text"
popis: "Use the warning text component when you need to warn users about something important, such as legal consequences of an action, or lack of action, that they might take"
jazyk: "en"
kanonicka: "https://design-system.service.gov.uk/components/warning-text/"
drobecky: ["Home", "Components"]
zdroj: "live"
wayback_snapshot: ""
stazeno: "2026-09-14 01:22:11"
znaku: 4333
slov: 626
kodovani: "utf-8"
sha256: "e0baf2131421773d00dad52b029c5c2769718a1f90e2fb022bdcdc5ee0abfa11"
---
# Warning text
- HTML
- Nunjucks
HTML
```
! Warning
You can be fined up to £5,000 if you do not register.
```
Nunjucks
Nunjucks macro options
Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.
Some options are required for the macro to work; these are marked as “Required” in the option description. Deprecated options are marked as “Deprecated”.
If you’re using Nunjucks macros in production with “html” options, or ones ending with “html”, you must sanitise the HTML to protect against [cross-site scripting exploits](https://developer.mozilla.org/en-US/docs/Glossary/Cross-site_scripting).
Primary options string **Required.**
If `html` is set, this is not required. Text to use within the warning text component. If `html` is provided, the `text` option will be ignored.
string **Required.**
If `text` is set, this is not required. HTML to use within the warning text component. If `html` is provided, the `text` option will be ignored.
string
The fallback text for the icon. Defaults to `"Warning"`.
string
Classes to add to the warning text.
object
HTML attributes (for example data attributes) to add to the warning text.
```
{% from "govuk/components/warning-text/macro.njk" import govukWarningText %} {{ govukWarningText({
text: "You can be fined up to £5,000 if you do not register.",
iconFallbackText: "Warning"
}) }}
```
## When to use this component
Use the warning text component when you need to warn users about something important, such as legal consequences of an action, or lack of action, that they might take.
## How it works
There are 2 ways to use the warning text component. You can use HTML or, if you are using [Nunjucks](https://mozilla.github.io/nunjucks/) or the [GOV.UK Prototype Kit](https://prototype-kit.service.gov.uk), you can use the Nunjucks macro.
- HTML
- Nunjucks
HTML
```
! Warning
You can be fined up to £5,000 if you do not register.
```
Nunjucks
Nunjucks macro options
Use options to customise the appearance, content and behaviour of a component when using a macro, for example, changing the text.
Some options are required for the macro to work; these are marked as “Required” in the option description. Deprecated options are marked as “Deprecated”.
If you’re using Nunjucks macros in production with “html” options, or ones ending with “html”, you must sanitise the HTML to protect against [cross-site scripting exploits](https://developer.mozilla.org/en-US/docs/Glossary/Cross-site_scripting).
Primary options string **Required.**
If `html` is set, this is not required. Text to use within the warning text component. If `html` is provided, the `text` option will be ignored.
string **Required.**
If `text` is set, this is not required. HTML to use within the warning text component. If `html` is provided, the `text` option will be ignored.
string
The fallback text for the icon. Defaults to `"Warning"`.
string
Classes to add to the warning text.
object
HTML attributes (for example data attributes) to add to the warning text.
```
{% from "govuk/components/warning-text/macro.njk" import govukWarningText %} {{ govukWarningText({
text: "You can be fined up to £5,000 if you do not register.",
iconFallbackText: "Warning"
}) }}
```
You might need to rewrite the hidden text (‘Warning’ in the example) to make it appropriate for your context.
## Help improve this component
To help make sure that this page is useful, relevant and up to date, you can:
- take part in the [‘Warning text’ discussion on GitHub](https://github.com/alphagov/govuk-design-system-backlog/issues/71) and share your research
- [propose a change on GitHub](https://github.com/alphagov/govuk-design-system/edit/main/src/components/warning-text/index.md) – read more about [how to propose changes in GitHub](/community/propose-a-content-change-using-github/)
## Need help?
If you’ve got a question about the GOV.UK Design System, [contact the team](/contact/).