A recipe app onboarding screen built with Tailwind CSS: diet preference chips, an allergy list with toggles and a cooking skill slider update a live recipe count and a personalised summary in a bottom sheet. It is an HTML mobile template for mobile sites and PWAs and can be packaged as an app with Capacitor. Use it as the dietary preferences step of a recipe, meal planning or grocery app.
How it works
The root .rco-app is a phone-width column with a top app bar (back, step dashes, Skip), the preferences in <main> and a sticky footer that shows how many recipes match. Each diet .rco-chip is a <button> with aria-pressed; CSS turns its plus sign into a check when pressed. Each allergy row has a .rco-switch button with role="switch". The cooking skill is a native range input with four levels.
script.js recomputes the match count on every change: it starts from data-rco-base, multiplies by the skill factor, by the data-rco-diet factor of each selected diet and by the data-rco-allergy factor of each avoided allergen.
Review my summary opens a bottom sheet ([data-rco-layer]) with the recipe count, maximum cooking time, weekly new recipes, the chosen diets, allergens and skill, plus a first suggestion. The sheet closes with Escape, the backdrop, the close button or Edit, and keeps focus inside while open. Start cooking simulates a save for 650 ms and shows a success state.
Customization
--rco-accentinstyle.css: the tomato red of chips, switches, the slider and buttons.data-rco-baseon.rco-app: the size of the recipe library used for the match count.data-rco-dieton a chip anddata-rco-allergyon a switch: the share of recipes that remain when it is selected; add chips or rows with your own values.SKILLSinscript.js: level names, maximum minutes, filter factor and the description under the slider.IDEASinscript.js: the first recipe suggestions shown in the summary for each diet.--rco-fillon.rco-app: the filled part of the slider track, set by the script from the slider value.
Use cases
- Recipe and cooking apps: the feed only shows dishes that fit the user's diet.
- Meal kit and meal planning apps: weekly plans skip allergens from the first box.
- Grocery delivery PWAs: shopping suggestions follow dietary restrictions.
Accessibility
Chips use aria-pressed, allergy toggles use role="switch" with aria-checked and the slider has a visible label, an <output> and aria-valuetext. The sheet is role="dialog" with aria-modal, traps Tab, closes with Escape and returns focus to the button that opened it. A polite live region announces each change with the new recipe count. Touch targets are at least 44 px and the sheet animation stops under prefers-reduced-motion.
Usage notes
The recipe numbers are sample data. Replace the timeout in the Start cooking handler with a fetch() call to save preferences to your API.