Skip to main content

Testing

Help us to improve the ONS Design System. Take part in a short study

Error

When to use this component

The error component is used to wrap form inputs and fieldsets to to show validation errors.

How to use this component

Generally speaking you should not need to call  onsError yourself as it is already called from within form input components. However if you need to create a pattern or component that requires a error you can use nunjucks’ call functionality  onsError.

Name Type Required Description
text string true The text that describes the error message
id string true The id that the error link can anchor to
attributes object false HTML attributes (for example data attributes) to add to the field
dsExample boolean false Defaulted to true if set in the Design System. Will not focus on error on page load - only for use in DS examples

Help improve this component

Let us know how we could improve this component or share your user research findings.

Discuss the ‘Error’ component on GitHub