Skip to content
IzzyBlazor

Enter all results ↑ ↓ move Esc close

Cookie consent

Ask before any cookie that isn't essential: a notice until the visitor chooses, a settings page, and a way for your code to check.

Preview

Cookies on MyApp

We use essential cookies to keep you signed in. With your OK, we'd also use analytics cookies to learn how MyApp is used. Cookie policy

Choose cookies

Add it to your project

  1. Sign in once on this machine
    izzy login

    The account is free. Create a free account

  2. Add the block
    izzy add block cookies

    Writes Components/Blocks/CookieNotice.razor, Components/Pages/Cookies.razor and Consent.cs and places it on MainLayout, before </AppShell>.

Settings

Each setting is a flag on izzy add. The flag syntax isn't final; for now it looks like this:

bash
izzy add block cookies 
Cookie consent settings
NameType or choicesDefaultDescription
SettingsRoutetextcookiesThe settings page's address, without the leading slash: the footer's Cookie settings link goes here.
PolicyHreftextprivacyWhere "Cookie policy" goes, such as the privacy page from izzy add block legal.
NametextCookieNoticeThe notice's component name.
PageNametextCookiesThe settings page's component name.
IntotextComponents/Layout/MainLayout.razorThe layout the notice is placed in, at the end of its AppShell. When every page runs in the browser, it goes in App.razor after Routes instead, rendered on the server.

Mode support

What works in each mode, Cookie consent
FeatureStaticInteractive
EverythingYesYes

Static: static server-side rendering, with no circuit and no WebAssembly. Interactive: Server, WebAssembly or Auto.

Accessibility

  • The notice is a region named by its heading, so screen readers can find it; it doesn't block the page or take focus.
  • Reject analytics and Accept all are the same size and style, so rejecting is as easy as accepting.
  • On the settings page each switch is named by its category; Essential is on and can't be turned off, and says so.

Components used

  • Card: Groups media, a header, body sections, actions and a footer in a box.
  • Heading: Renders headings 1 to 6, with fluid sizes and section links.
  • TextBlock: Sets paragraphs, captions and labels in the library's text styles.
  • Anchor: Renders a text link, internal or external.
  • Button: Submits or resets a form, follows a link or runs C#.
  • Stack: Lays out its children in a row or a column, changing with the screen width.
  • Grid: Lays out its children in columns set by breakpoint, by minimum width or by template.
  • Spacer: Pushes the rest of a row to the end.
  • Form: Posts its fields on static pages and validates them live on interactive pages.
  • Switch: Shows an on/off switch that posts like a checkbox.
  • Row: Lines up buttons, badges or fields side by side, with a gap between them.
  • Column: Stacks fields, cards or text from top to bottom, with even spacing.

Connection lost

Rejoining the server…