Skip to Content

DietaryInformation

Display caller-supplied dietary tags and allergen information with readable labels, optional icons, compact or expanded layouts, and an accessible popover.

DietaryInformation displays labels provided by the restaurant or application. It never infers ingredients, allergens, or dietary suitability from a dish name or description.

Beta API maturity: Beta.

TypeScript example

import {
  DietaryInformation,
  type Allergen,
  type DietaryTag,
} from "@puzzle-ui/pieces";

const tags: DietaryTag[] = [
  { id: "plant-based", label: "Plant-based" },
];
const allergens: Allergen[] = [
  { id: "sesame", label: "Sesame" },
];

<DietaryInformation tags={tags} allergens={allergens} />;

Compact and expanded variants

Both variants always display the supplied text labels. Expanded mode also shows the supplied item descriptions. Icons are optional and decorative; they never replace the label.

compact - Show readable tags with minimal detail.

390 × 844

expanded - Include descriptions for supplied labels.

390 × 844

Optional details popover

Use the existing Puzzle UI Popover when descriptions should be available on demand. The text labels remain visible outside the popover.

390 × 844

API

PropTypeRequiredDefaultDescription
tagsreadonly DietaryTag[]No[]Dietary labels explicitly supplied by the caller.
allergensreadonly Allergen[]No[]Allergen labels explicitly supplied by the caller.
variant"compact" | "expanded"No"compact"Compact labels or labels with descriptions.
dietaryHeadingReactNodeNo"Dietary"Visible heading for the dietary tags.
allergenHeadingReactNodeNo"Allergens"Visible heading for the allergens.
showDetailsPopoverbooleanNofalseAdds a button that opens the existing UI Popover with supplied details.
detailsLabelReactNodeNo"Details"Accessible button content for the popover trigger.
popoverTitleReactNodeNo"Dietary and allergen information"Visible and accessible popover title.
closeLabelstringNo"Close"Accessible name for the popover close button.
classNamestringNo—Additional class on the wrapper.

Shared item types

DietaryTag and Allergen share the extensible DietaryInformationItem shape: a unique id, a caller-configured label, and optional icon and description. Labels and descriptions accept ReactNode; filter options use plain text labels so native select controls remain accessible. The component returns no wrapper when both arrays are empty and rejects duplicate or empty IDs within either array.

Safety and responsibility boundary

The application must provide accurate, current allergen and dietary information from its own source. Pieces does not inspect ingredients, make medical claims, certify that a dish is safe for a person, or infer missing information. Keep labels visible even when icons are supplied, and do not use color as the only distinction.

Responsive behavior and accessibility

  • Labels wrap in compact and expanded layouts without fixed widths.
  • Semantic lists and visible group headings communicate dietary tags and allergens separately.
  • Decorative icons are hidden from assistive technology because the visible text label conveys the information.
  • The optional popover uses the existing keyboard-accessible UI primitive; disclosure details are not required to understand the visible labels.

Theme support and customization

The component uses Puzzle Theme border, surface, text, spacing, and focus-ring tokens. Pass custom labels and icon React nodes through each item; icons are decorative, while labels remain visible. showDetailsPopover composes the existing UI Popover rather than introducing a new overlay system.

  • Dish Card for presenting dietary details with a menu item.
  • Restaurant Menu for categories, menu navigation, and caller-supplied dietary filtering.
  • Popover for the underlying interactive primitive.

Use the component in either supported framework; see Framework Integration for Next.js and TanStack Start guidance.