{% extends 'base.html.twig' %} {% block title %}Search Bar - Design System - Bubul{% endblock %} {% block body %}
{% verbatim %}{% include '_molecules/search-bar/search-bar.html.twig' with {
placeholder: 'Rechercher un cours...',
action: '/courses',
showShortcut: true,
clearable: true
} %}{% endverbatim %}
Fichier : templates/_molecules/search-bar/search-bar.html.twig
Paramètre : variant
Default
Bordered
Filled (sur fond sombre)
Paramètre : size
Small (sm)
Medium (md) - défaut
Large (lg)
Paramètre : showButton: true
Paramètre : showShortcut: true
Le raccourci est masqué sur mobile pour économiser l'espace.
Le bouton clear apparaît quand il y a du texte
| Paramètre | Type | Défaut | Description |
|---|---|---|---|
placeholder | string | 'Rechercher...' | Texte du placeholder |
value | string | '' | Valeur initiale |
name | string | 'q' | Nom du champ |
action | string | null | URL du formulaire |
showButton | bool | false | Afficher bouton submit |
buttonText | string | 'Rechercher' | Texte du bouton |
showShortcut | bool | false | Afficher raccourci |
shortcut | string | '⌘K' | Raccourci affiché |
instant | bool | false | Recherche temps réel |
clearable | bool | true | Bouton effacer |
size | string | 'md' | sm, md, lg |
variant | string | 'default' | default, bordered, filled |
class | string | '' | Classes additionnelles |
// Écouter les recherches instantanées (avec debounce 300ms)
document.getElementById('my-search').addEventListener('instantSearch', (e) => {
console.log('Recherche:', e.detail.query);
// Effectuer la recherche AJAX...
});