404 Page
NotFoundPage is a ready-made "page not found" screen: a large status code, a title, a short explanation and the way out, a link home and (with onBack) a "go back" button. It is not tied to 404: pass code, title and description for a 403, a 500 or a "coming soon" page. children render under the buttons (a search box, a list of suggestions). Use homeHref={null} to drop the home link, linkComponent / linkProp for a router link, and fullScreen to center it in the whole viewport.
404: Page not found
The page you are looking for does not exist or has moved.
403: Only Gru can go in here
Ask Gru to add you to the Minion crew, or go and look for bananas instead.
Props
codestringDefault:'404'Large status code shown above the title (read out before the title by screen readers).
titlestringDefault:'Page not found'Heading of the page.
descriptionstringDefault:'The page you are looking for does not exist or has moved.'Short explanation; pass an empty string to hide it.
homeHrefstring | nullDefault:'/'Destination of the home link;
nullhides it.homeLabelstringDefault:'Go home'Text of the home link.
onBack() => voidAdds a "go back" button that calls this (e.g.
() => navigate(-1)).backLabelstringDefault:'Go back'Text of the back button.
linkComponentElementTypeDefault:'a'Component used for links, e.g. a router Link.
linkPropstringDefault:'href'Name of the destination prop on
linkComponent(e.g. "to" for react-router).fullScreenbooleanDefault:falseCenter it in the whole viewport instead of filling the space it is given.
classNamestringDefault:''Extra classes for the root element.
childrenReactNodeExtra content under the buttons.
| Prop | Type | Default | Description |
|---|---|---|---|
code | string | '404' | Large status code shown above the title (read out before the title by screen readers). |
title | string | 'Page not found' | Heading of the page. |
description | string | 'The page you are looking for does not exist or has moved.' | Short explanation; pass an empty string to hide it. |
homeHref | string | null | '/' | Destination of the home link; null hides it. |
homeLabel | string | 'Go home' | Text of the home link. |
onBack | () => void | – | Adds a "go back" button that calls this (e.g. () => navigate(-1)). |
backLabel | string | 'Go back' | Text of the back button. |
linkComponent | ElementType | 'a' | Component used for links, e.g. a router Link. |
linkProp | string | 'href' | Name of the destination prop on linkComponent (e.g. "to" for react-router). |
fullScreen | boolean | false | Center it in the whole viewport instead of filling the space it is given. |
className | string | '' | Extra classes for the root element. |
children | ReactNode | – | Extra content under the buttons. |