Synertech Web/ui v0.57.5 Site Storybook

Documentation / Affichage & médias

Indicator

Compatible serveur@synertech/uiVoir dans Storybook

Un repère visuel posé sur un autre élément ou à côté d’un texte. Quatre variantes : dot (une pastille), count (un compteur plafonné par maxCount, 99+ au-delà), status (un état de présence en bas à droite, liseré par défaut) et legend (une pastille suivie d’un libellé, pour une légende).

Avec des enfants, l’indicateur les enveloppe dans un conteneur relatif et se place selon placement (neuf positions) ; offset le garde à l’intérieur du cadre au lieu de le centrer sur le coin. La pastille est purement visuelle : quand elle porte une information, doublez-la d’un texte pour les lecteurs d’écran. Composant sans hook, compatible serveur.

Exemples

Pastille de base

Sans variante, une pastille se pose en haut à droite de l’élément enveloppé.

Ouvrir dans un onglet
import { Button, Indicator } from "@synertech/ui";

const BellIcon = () => (
  <svg
    className="h-5 w-5"
    fill="none"
    viewBox="0 0 24 24"
    stroke="currentColor"
    strokeWidth={2}
    aria-hidden="true"
  >
    <path
      strokeLinecap="round"
      strokeLinejoin="round"
      d="M15 17h5l-1.4-1.4A2 2 0 0118 14.2V11a6 6 0 10-12 0v3.2a2 2 0 01-.6 1.4L4 17h5m6 0a3 3 0 11-6 0"
    />
  </svg>
);

export function Basic() {
  return (
    <Indicator color="error">
      <Button icon={<BellIcon />} aria-label="Notifications, nouvelles alertes" />
    </Indicator>
  );
}

Compteur

variant="count" affiche count et plafonne au-delà de maxCount (99 par défaut).

Ouvrir dans un onglet
import { Button, Indicator } from "@synertech/ui";

const BellIcon = () => (
  <svg
    className="h-5 w-5"
    fill="none"
    viewBox="0 0 24 24"
    stroke="currentColor"
    strokeWidth={2}
    aria-hidden="true"
  >
    <path
      strokeLinecap="round"
      strokeLinejoin="round"
      d="M15 17h5l-1.4-1.4A2 2 0 0118 14.2V11a6 6 0 10-12 0v3.2a2 2 0 01-.6 1.4L4 17h5m6 0a3 3 0 11-6 0"
    />
  </svg>
);

export function Count() {
  return (
    <div className="flex items-center gap-8">
      <Indicator variant="count" count={3}>
        <Button icon={<BellIcon />} aria-label="3 notifications" />
      </Indicator>
      <Indicator variant="count" count={150} maxCount={99} bordered>
        <Button icon={<BellIcon />} aria-label="150 notifications" />
      </Indicator>
    </div>
  );
}

Statut de présence

variant="status" se place en bas à droite avec un liseré ; pulse attire l’œil.

Ouvrir dans un onglet
import { Avatar, Indicator } from "@synertech/ui";

export function Status() {
  return (
    <div className="flex items-center gap-6">
      <Indicator variant="status" color="success" title="En ligne">
        <Avatar fallback="CD" alt="Camille Durand" />
      </Indicator>
      <Indicator variant="status" color="warning" title="Absent">
        <Avatar fallback="HM" alt="Hugo Martin" />
      </Indicator>
      <Indicator variant="status" color="error" pulse title="Ne pas déranger">
        <Avatar fallback="LB" alt="Léa Bernard" />
      </Indicator>
    </div>
  );
}

Position

placement choisit l’un des neuf emplacements ; offset garde le repère dans le cadre.

Ouvrir dans un onglet
import { Indicator } from "@synertech/ui";

export function Placement() {
  return (
    <div className="flex items-center gap-8">
      <Indicator placement="top-left" color="primary">
        <div className="h-16 w-16 rounded-md bg-gray-100 dark:bg-gray-800" />
      </Indicator>
      <Indicator placement="bottom-center" color="primary">
        <div className="h-16 w-16 rounded-md bg-gray-100 dark:bg-gray-800" />
      </Indicator>
      <Indicator placement="top-right" color="primary" offset>
        <div className="h-16 w-16 rounded-md bg-gray-100 dark:bg-gray-800" />
      </Indicator>
    </div>
  );
}

Légende

variant="legend" aligne une pastille et son label, sans enfant à envelopper.

Ouvrir dans un onglet
import { Indicator } from "@synertech/ui";

export function Legend() {
  return (
    <div className="flex flex-wrap gap-4">
      <Indicator variant="legend" color="primary" label="Trafic direct" />
      <Indicator variant="legend" color="success" label="Recherche" />
      <Indicator variant="legend" color="warning" label="Référents" />
      <Indicator variant="legend" color="purple" label="Réseaux sociaux" />
    </div>
  );
}

Référence d’API

Composants

Indicator

ComposantCompatible serveur
import { Indicator } from "@synertech/ui";

Props — IndicatorProps

PropTypeDéfautDescription
borderColor string —

Couleur de l’anneau d’une marque bordered, en classes Tailwind (ring-blue-500). Elle remplace celle par défaut dans les deux thèmes : écrivez une classe dark: à côté pour une couleur sombre à elle.

bordered boolean —
children ReactNode —
color IndicatorColor —
count number —
label string —
maxCount number —
offset boolean —
placement IndicatorPlacement —
pulse boolean —
size IndicatorSize —
variant IndicatorVariant "dot"

+ 277 attributs natifs hérités de HTMLAttributes, AriaAttributes, DOMAttributes (className, id, aria-*, gestionnaires d’événements…).

Types

type IndicatorColor = | "default"
  | "primary"
  | "success"
  | "warning"
  | "error"
  | "info"
  | "dark"
  | "purple"
  | "indigo"
  | "teal"
type IndicatorPlacement = | "top-left"
  | "top-center"
  | "top-right"
  | "center-left"
  | "center"
  | "center-right"
  | "bottom-left"
  | "bottom-center"
  | "bottom-right"
type IndicatorSize = "xs" | "sm" | "md" | "lg" | "xl"
type IndicatorVariant = "dot" | "count" | "status" | "legend"