Synertech Web/ui v0.57.5 Site Storybook

Documentation / Navigation & actions

ButtonGroup

Client@synertech/uiOpen in Storybook

Joins several Button into a single block: the inner corners disappear and the borders overlap, horizontally or vertically. The group carries role="group".

It also works as a single-choice selector: give each button a value, then selectedValue and onChange to the group — the matching button gets the selected state. The group imposes its size on all its buttons and only keeps components as children (raw HTML elements are ignored). The selected state is visual only: add aria-pressed to announce it to screen readers.

Examples

Basic usage

Related actions grouped together; each button keeps its own onClick.

Open in a tab
import { Button, ButtonGroup } from "@synertech/ui";

const outline = {
  bgColor: "bg-white hover:bg-gray-50 border border-gray-300",
  textColor: "text-gray-700",
};

export function Basic() {
  return (
    <ButtonGroup>
      <Button {...outline} onClick={() => console.log("Copier")}>
        Copier
      </Button>
      <Button {...outline} onClick={() => console.log("Couper")}>
        Couper
      </Button>
      <Button {...outline} onClick={() => console.log("Coller")}>
        Coller
      </Button>
    </ButtonGroup>
  );
}

Single choice

selectedValue and onChange turn the group into a view selector.

Open in a tab
import { useState } from "react";
import { Button, ButtonGroup } from "@synertech/ui";

const outline = {
  bgColor: "bg-white hover:bg-gray-50 border border-gray-300",
  textColor: "text-gray-700",
};

export function SingleChoice() {
  const [period, setPeriod] = useState("mois");

  return (
    <ButtonGroup selectedValue={period} onChange={setPeriod}>
      {["jour", "semaine", "mois", "année"].map((value) => (
        <Button key={value} value={value} aria-pressed={period === value} {...outline}>
          {value.charAt(0).toUpperCase() + value.slice(1)}
        </Button>
      ))}
    </ButtonGroup>
  );
}

Icon buttons

A list / grid toggle; each icon button carries its aria-label.

Open in a tab
import { useState } from "react";
import { Button, ButtonGroup } from "@synertech/ui";

const ListIcon = () => (
  <svg fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2} aria-hidden="true">
    <path strokeLinecap="round" strokeLinejoin="round" d="M4 6h16M4 12h16M4 18h16" />
  </svg>
);

const outline = {
  bgColor: "bg-white hover:bg-gray-50 border border-gray-300",
  textColor: "text-gray-700",
};

const GridIcon = () => (
  <svg fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2} aria-hidden="true">
    <path
      strokeLinecap="round"
      strokeLinejoin="round"
      d="M4 4h6v6H4zM14 4h6v6h-6zM4 14h6v6H4zM14 14h6v6h-6z"
    />
  </svg>
);

export function IconToggle() {
  const [view, setView] = useState("liste");

  return (
    <ButtonGroup size="sm" selectedValue={view} onChange={setView}>
      <Button
        value="liste"
        icon={<ListIcon />}
        aria-label="Vue en liste"
        aria-pressed={view === "liste"}
        {...outline}
      />
      <Button
        value="grille"
        icon={<GridIcon />}
        aria-label="Vue en grille"
        aria-pressed={view === "grille"}
        {...outline}
      />
    </ButtonGroup>
  );
}

Vertical and full width

orientation="vertical" stacks the buttons; fullWidth stretches them across the full width.

Open in a tab
import { Button, ButtonGroup } from "@synertech/ui";

const outline = {
  bgColor: "bg-white hover:bg-gray-50 border border-gray-300",
  textColor: "text-gray-700",
};

export function VerticalAndFullWidth() {
  return (
    <div className="space-y-6">
      <ButtonGroup orientation="vertical">
        <Button {...outline}>Boîte de réception</Button>
        <Button {...outline}>Brouillons</Button>
        <Button {...outline}>Envoyés</Button>
      </ButtonGroup>
      <ButtonGroup fullWidth>
        <Button {...outline}>Précédent</Button>
        <Button>Suivant</Button>
      </ButtonGroup>
    </div>
  );
}

API reference

Components

ButtonGroup

ComponentClient
import { ButtonGroup } from "@synertech/ui";

Props — ButtonGroupProps

PropTypeDefaultDescription
children• React.ReactNode —
className string —
fullWidth boolean false
onChange (value: string) => void —
orientation "horizontal" | "vertical" "horizontal"
selectedValue string —
size "sm" | "md" | "lg" | "xl" —