/** * @file Inspector button group component for segmented controls */ import * as React from "react"; import styles from "./InspectorButtonGroup.module.css"; export type InspectorButtonGroupOption = { value: T; /** Label content - can be text or an icon */ label: React.ReactNode; /** Accessible label for the option (used when label is an icon) */ "aria-label"?: string; }; export type InspectorButtonGroupProps = { /** Available options */ options: InspectorButtonGroupOption[]; /** Currently selected value */ value: T; /** Callback when selection changes */ onChange: (value: T) => void; /** Additional CSS class */ className?: string; /** Disable all options */ disabled?: boolean; /** Accessible label for the group */ "aria-label"?: string; /** Visual size variant */ size?: "default" | "compact"; }; /** * Segmented button group for selecting between mutually exclusive options. * Commonly used for toggle-style selections like alignment, sizing modes, etc. * Does not include external layout - layout should be controlled externally. */ export function InspectorButtonGroup({ options, value, onChange, className, disabled, "aria-label": ariaLabel, size = "default", }: InspectorButtonGroupProps): React.ReactElement { const groupClassName = [styles.group, className].filter(Boolean).join(" "); return (
{options.map((option) => ( ))}
); } InspectorButtonGroup.displayName = "InspectorButtonGroup";