The TotalHits component displays the total number of matching search results, providing users with immediate feedback about the search query scope.
<twig:Mezcalito:UxSearch:TotalHits />| Variable | Type | Description |
|---|---|---|
totalHits |
int | Total number of matching results |
attributes |
ComponentAttributes | HTML attributes for the container |
| Block Name | Description |
|---|---|
content |
Main block containing the total hits display - override to customize formatting |
{% block content %}
<span {{ attributes.defaults({
'class': 'ux-search-total-hits'
}) }} >
{{ 'results'|trans({'%count%': totalHits}, domain='mezcalito_ux_search') }}
</span>
{% endblock %}<div class="ux-search__stats">
<span class="ux-search-total-hits">
10000 results
</span>
</div>This ensures screen readers announce result count changes when users apply filters or search.
The default translation key supports pluralization:
# translations/mezcalito_ux_search.en.yaml
results: '{0} No results|{1} 1 result|]1,Inf[ %count% results'# translations/mezcalito_ux_search.fr.yaml
results: '{0} Aucun résultat|{1} 1 résultat|]1,Inf[ %count% résultats'Default classes:
.ux-search-total-hits- Main span element containing the result count
- Hits - Display the actual search results
- Pagination - Navigate through result pages
- HitsPerPage - Control results per page
- Layout - Root container (includes TotalHits in stats block)