Cookie banner
Allow users to accept or reject cookies which are not essential to making your service work.
A banner with one message. Use Root and MessageComposite for more.
Read the Design System guidance for cookie banner
Import
import * as CookieBanner from 'govuk-react/cookie-banner';Examples
Default
Code
<CookieBanner.Root aria-label="Cookies on [name of service]">
<CookieBanner.MessageComposite
heading="Cookies on [name of service]"
actions={
<>
<Button type="button">Accept analytics cookies</Button>{' '}
<Button type="button">Reject analytics cookies</Button> <Link href="#">View cookies</Link>
</>
}
>
<Body>We use some essential cookies to make this service work.</Body>
<Body>
We’d also like to use analytics cookies so we can understand how you use the service and make improvements.
</Body>
</CookieBanner.MessageComposite>
</CookieBanner.Root>API reference
CookieBanner.Root
Allow users to accept or reject cookies which are not essential to making your service work.
No props of its own. Other props are passed to the element it renders.
CookieBanner.ButtonGroup
No props of its own. Other props are passed to the element it renders.
CookieBanner.Composite
Allow users to accept or reject cookies which are not essential to making your service work.
A banner with one message. Use Root and MessageComposite for more.
| Prop | Type |
|---|---|
headingThe heading that displays in the message. | ReactNode |
actionsThe buttons and links that you want to display in the message. | ReactNode |
CookieBanner.Content
No props of its own. Other props are passed to the element it renders.
CookieBanner.GridColumn
| Prop | Type |
|---|---|
width | ColumnWidth | "full-from-desktop" | "one-half-from-desktop" | "one-third-from-desktop" | "two-thirds-from-desktop" | "one-quarter-from-desktop" | "three-quarters-from-desktop" |
CookieBanner.GridRow
Organise the layout of the page into blocks.
No props of its own. Other props are passed to the element it renders.
CookieBanner.Heading
No props of its own. Other props are passed to the element it renders.
CookieBanner.Message
No props of its own. Other props are passed to the element it renders.
CookieBanner.MessageComposite
| Prop | Type |
|---|---|
headingThe heading that displays in the message. | ReactNode |
actionsThe buttons and links that you want to display in the message. | ReactNode |