Dietary Preferences
The dietary preferences feature allows customers to set their dietary needs and allergen restrictions, automatically filtering menu items to show only what's suitable for them.
Overview
Dietary preferences are managed entirely on the client side , no dietary data is sent to any server. This design ensures:
- Privacy: Customer dietary data never leaves their device.
- Speed: Filtering is instant, no network request needed.
- Offline support: Works even without internet connectivity.
- Guest-friendly: No login required to use the feature.
Preferences are stored in localStorage and persist across sessions on the same device.
Setting Dietary Preferences
Accessing the Preferences Sheet
- Tap the Sliders icon or Set allergies & dietary preferences link in the menu header.
- The DietaryPreferencesSheet opens as a slide-over panel.
Configuring Preferences
The sheet has two sections:
Dietary Flags
Select dietary patterns you follow:
- Vegetarian
- Vegan
- Gluten-free
- Dairy-free
- Halal
- Keto
- Paleo
- Nut-free
- Sugar-free
Selecting a dietary flag positively filters items , only items tagged with matching dietary tags are shown.
Allergen Avoidances
Select allergens you need to avoid:
- Peanuts
- Tree nuts
- Milk
- Eggs
- Soy
- Wheat
- Fish
- Shellfish
- Sesame
Allergen selections trigger warnings or blocks depending on your strictness setting.
Strictness Level
Choose how allergen warnings behave:
| Level | Behavior |
| Warn | Items containing selected allergens are highlighted with a warning indicator, but ordering is allowed |
| Block | Items containing selected allergens are greyed out and cannot be added to the cart |
How Filtering Works
Dietary Flags (Positive Filter)
- An item tagged as
vegetarianwill show when the customer selects Vegetarian. - Items without the matching tag are not hidden , dietary flags only positively filter, they never exclude.
This design choice (documented in the codebase as an "honesty note"): "Absence of a tag is not proof , dietary flags are positive markers, so they never raise a false alarm."
Allergens (Warn/Block)
- Items with explicit allergen tags matching the customer's avoids are warned or blocked based on strictness.
- The blocking is based on the item's explicit
allergenslist.
Visual Indicators
On the public menu:
- Items that conflict with dietary preferences show a small warning badge.
- In "block" mode, affected items are visually dimmed.
- A summary chip in the header shows active dietary preferences.
Signed-in Customers
Signed-in customers can optionally persist their dietary preferences to their account for cross-device restore:
- Set preferences in the DietaryPreferencesSheet.
- Sign in to your account.
- Preferences are saved to your profile.
- On another device, sign in to restore your preferences.
This is a convenience feature , the device-local profile always remains the primary source of truth.
Implementation Details
- Hook:
useDietaryProfile(), provides the current profile and update functions. - Evaluation:
evaluateItemDietary(), checks an item against the profile and returns match/warning/block status. - Source of truth: localStorage (
dietary_preferenceskey). - No server storage: Dietary data is never sent to the API.