Skip to content

DisabledReason ​

Why a row cannot be picked, in a tooltip beside it, so the sentence does not widen the menu.

tsx
import { DisabledReason } from '@adecore/ui';
tsx
import { DisabledReason, IconButton, Menu } from '@adecore/ui';
import { Ellipsis } from 'lucide-react';

function pushReason(): string | null {
    return 'Nothing to push: the branch has no commits the remote lacks.';
}

export default function DisabledReasonDemo() {
    return (
        <Menu.Root>
            <IconButton icon={Ellipsis} label="Branch actions" render={<Menu.Trigger />} />
            <Menu.Popup>
                <DisabledReason reason={null}>
                    <Menu.Item>Pull</Menu.Item>
                </DisabledReason>
                <DisabledReason reason={pushReason()}>
                    <Menu.Item disabled>Push</Menu.Item>
                </DisabledReason>
            </Menu.Popup>
        </Menu.Root>
    );
}

Open the menu and hover Push. With reason={null} the row renders unchanged, so you can wrap every row the same way.

Props ​

PropTypeDefault
reasonstring | nullRequired.
childrenReactElementRequired. The row.

DisabledReasonProps is an exported type.

Licenses and third-party notices are listed in each package.