Skip to main content
Docs-Menü

HTML & JS

Die Elemente, Aktionen, Slots, Zustände und CSS Custom Properties, auf die das Skript von 5zero reagiert.

Bewertungen werden mit Liquid gerendert, also sind sie ohne JavaScript lesbar. Das Skript von 5zero, das die App-Einbettung 5zero Core lädt, fügt nur Interaktion hinzu: mehr Bewertungen laden, sortieren, filtern, suchen, Formulare absenden und Slider bewegen. Es reagiert auf die Custom Elements und data-fo-*-Attribute unten, nie auf CSS-Klassen, also bleiben dein Markup und deine Klassen ganz deine.

Komplette Beispiele findest du in der Review List, der Review Form und dem Reviews Slider.

JS reacts only to the elements and data-fo-* attributes below, never to CSS classes.

Elements

ElementPurpose
<fo-reviews>Review list with load more, sort, filter, search
<fo-review-form>Review form: validation, uploads, submit
<fo-slider>Carousel buttons for any scroll-snap track

Actions (data-fo-action)

ValueWhereEffect
load-more<fo-reviews>Appends the next page
sort<fo-reviews>, on a <select> or a button with valueReloads sorted by the value; sets aria-pressed on sort buttons
search<fo-reviews>, on an <input>Reloads with the search term 1 second after typing stops, at once on Enter or on submit of its form
filter<fo-reviews>, with data-fo-filterToggles the filter; sets aria-pressed
filter<fo-reviews>, on a <select>Sets the selected filter, replacing the one it set before; empty value clears it
slide-prev, slide-next<fo-slider>Scrolls the track
open-modalanywhereOpens the <dialog> named by aria-controls; on a media link without it, opens the image or video in a dialog. An element named by aria-controls that is not a dialog is scrolled to. A missing one does nothing; in the Theme Editor an alert says why
close-modalanywhereCloses the <dialog> named by aria-controls, else the one it is in
submit-all<fo-review-form> with itemsSubmits every item that is idle or error
read-more<fo-reviews>, inside a reviewShows or shortens the review's data-fo-clamp text; sets aria-expanded

Slots

AttributeMeaning
data-fo-itemsContainer the review items or form items are rendered into
data-fo-template="review"<template> with the markup for loaded reviews
data-fo-template="item"<template> inside <fo-review-form>: the form loads the review request from the URL's id and renders one item per product into data-fo-items
data-fo-itemRoot of one rendered form item; holds its own <form data-fo-form> and data-fo-state
data-fo-field="name"Sets the element's text; name:attribute sets an attribute, name:--property a CSS custom property
data-fo-if="name"Removed when the value is empty; outside templates (has_next_page, no_results, error_message) hidden instead
data-fo-repeat="name"Repeats a child <template> per entry, e.g. media
data-fo-show="state"Shown only in these states, separated by spaces, e.g. idle error. Follows the nearest data-fo-item, else <fo-review-form>
data-fo-trackScroll container of <fo-slider>
data-fo-formThe <form> inside <fo-review-form>
data-fo-review-handleHandle of a rendered review
data-fo-clampText shortened by CSS. The script shows the review's read-more button only when the text is cut off, and sets data-fo-expanded while it is open
data-fo-filter-countThe number of active filters; hidden while none is active
data-fo-sort-labelThe text of the pressed sort button. A sort button inside a popover also closes it
data-fo-filterFilter value: rating:1 … rating:5, status:verified, status:unverified, product:<id> (only reviews of the whole product, not of one of its variants), variant:<id>

Fields of a loaded review, for data-fo-field, data-fo-if and data-fo-repeat in <template data-fo-template="review">:

FieldHolds
handleThe review's handle
titleTitle, translated
bodyReview text, translated
authorPublic author name
ratingStar rating, 1 to 5. Draw stars with <span class="fo-stars" data-fo-field="rating:--fo-rating"></span>
dateWhen it was written, in the shopper's language, like Oct 13, 2026
submitted_atWhen it was written, as an ISO date. For <fo-relative-time data-fo-field="submitted_at:datetime">, which shows the time since it; text inside the element stays in the HTML and only shows without the script
statusverified_buyer, verified_reviewer or unverified
status_labelThe status as text, like "Verified Buyer"
merchant_replyYour reply, translated
reply_dateWhen you replied, formatted like date
replied_atWhen you replied, as an ISO date
product, variantProduct and variant title, for reviews of the current page's product
mediaPhotos and videos; each entry has url, image_url and video_url
additional_attributesAttribute answers; each entry has attribute_id, question, label, left_label, right_label and, for scales, percent
has_next_pageWhether more reviews can be loaded
no_resultsWhether the search and filters match no review
error_messageThe error, when loading failed

Fields inside <fo-review-form>:

FieldHolds
error_messageThe error, when sending failed
progressUpload progress, 0 to 100
filesThe picked files, for data-fo-repeat; each entry has name

Fields of a form item, inside <template data-fo-template="item">:

FieldHolds
product_title, variant_titleTitles of the product to review
image_urlThe variant's image, else the product's
urlThe product's page
review_handle, submitted_atSet when the item was already reviewed

State

WhereAttributeValues
<fo-review-form>, [data-fo-item]data-fo-stateloading (items load) | idle | submitting | success | error | reviewed (already reviewed)
<fo-reviews>aria-busytrue while loading, and while a search waits for typing to stop
Filter and sort buttonsaria-pressedtrue | false
Slider buttonsdisabledSet at the start and end of the track

Config (on the element)

AttributeHolds
data-fo-product-idThe product whose reviews to load or review
data-fo-variant-idThe variant
data-fo-page-sizeReviews per page
data-fo-totalTotal number of reviews; load more hides once all are shown
data-fo-skipped-reviewsOptional, on data-fo-items: newest reviews left out of the items, like featured ones shown above them. Load more continues after them
data-fo-sortStart order: submitted_at:desc, submitted_at:asc, rating:desc or rating:asc. Rendered reviews are expected newest first; with another start order the script loads them sorted
data-fo-scopeWhich reviews: product, products (every product review of the shop, without store reviews), store or mixed
data-fo-autoplayOn <fo-slider>: seconds per slide. Moves on by itself, back to the start at the end; pauses while the slider is pointed at, touched or focused, and stays off with reduced motion
data-fo-text-*Texts only the script shows. English when not set: see the table below

Texts for data-fo-text-*:

AttributeElementShown when
data-fo-text-error<fo-reviews>, <fo-review-form>Loading or sending failed
data-fo-text-anonymous<fo-reviews>A loaded review has no author name
data-fo-text-read-more, data-fo-text-read-less<fo-reviews>The read-more button's text when the review is shortened or open
data-fo-text-missing-rating<fo-review-form>The form is sent without a star rating
data-fo-text-upload-failed<fo-review-form>A photo or video could not be uploaded
data-fo-text-test-mode<fo-review-form>A review is sent from the post-purchase form's preview
data-fo-text-close<fo-reviews>, <fo-slider>The close button of the dialog that opens a review's photo or video

Form fields

rating, title, body, author, media; attribute[<attribute_id>] is reserved. Layout is free. An author input outside the item forms applies to all items and is pre-filled with the order's first name.

CSS custom properties

--fo-rating (0–5) and --fo-percent (0–100) on any element; the optional base CSS uses them for stars and bars.

<span class="fo-stars" style="--fo-rating: 4.6"></span> draws five stars filled to the rating (fo-base.css, loaded by our blocks and the card ratings embed). Style with --fo-star-color and --fo-star-size.