diff --git a/weave-js/src/components/ToggleButtonGroup.tsx b/weave-js/src/components/ToggleButtonGroup.tsx
index 65b2c538975..eca93e95657 100644
--- a/weave-js/src/components/ToggleButtonGroup.tsx
+++ b/weave-js/src/components/ToggleButtonGroup.tsx
@@ -9,6 +9,7 @@ import {Tailwind} from './Tailwind';
export type ToggleOption = {
value: string;
icon?: IconName;
+ isDisabled?: boolean;
};
export type ToggleButtonGroupProps = {
@@ -37,7 +38,10 @@ export const ToggleButtonGroup = React.forwardRef<
}
const handleValueChange = (newValue: string) => {
- if (newValue !== value) {
+ if (
+ newValue !== value &&
+ options.find(option => option.value === newValue)?.isDisabled !== true
+ ) {
onValueChange(newValue);
}
};
@@ -49,34 +53,39 @@ export const ToggleButtonGroup = React.forwardRef<
onValueChange={handleValueChange}
className="flex gap-px"
ref={ref}>
- {options.map(({value: optionValue, icon}) => (
-
-
-
- ))}
+ {options.map(
+ ({value: optionValue, icon, isDisabled: optionIsDisabled}) => (
+
+
+
+ )
+ )}
);