MenuItem

Type: React component

How to get MenuItem?

JavaScript

import { MenuItem } from 'fds/components';

Visually renders the outer container of a menu item and standardizes things like disabled, hovered and selected states while leaving the actual content arbitrary.

Should be rendered inside a Menu or MenuGroup.

Keyboard behavior:

  • Enter: call the onClick prop when focused/hovered and isDisabled is false.

Props

  1. icon

    (Optional)

    Type: String

    The name of the icon displayed in the component.

    This should be one of the Font Awesome icons. Do not include the fa- prefix, just use the icon names as-is from the documentation.

    Default value

  2. iconAfter

    (Optional)

    Type: String

    The name of the icon displayed after the component.

    This should be one of the Font Awesome icons. Do not include the fa- prefix, just use the icon names as-is from the documentation.

    Default value

  3. isDisabled

    (Optional)

    Type: Boolean

    Whether or not the component should be rendered in a disabled state.

    Default value

  4. isHovered

    (Optional)

    Type: Boolean

    Whether or not the component is currently hovered.

    Default value

  5. isSelected

    (Optional)

    Type: Boolean

    Whether or not the component should be rendered in a selected state.

    Default value

  6. keyBindingLabel

    (Optional)

    Type: String

    The human readable label indicating a key binding (shortcut) displayed in the component.

    Default value

  7. label

    (Optional)

    Type: String

    The human readable label displayed in the component.

    Default value

  8. onClick

    (Optional)

    Type: Function

    A callback that is called whenever the component is clicked and is not in a disabled state.

    For more information about React and "events", check the React documentation

    Arguments

    Default value

  9. onMouseEnter

    (Optional)

    Type: Function

    A callback that is called whenever the pointer is moved over the component. This callback is only fired when the pointer enters the component.

    For more information about React and "events", check the React documentation

    Arguments

    Default value

  10. onMouseLeave

    (Optional)

    Type: Function

    A callback that is called whenever the pointer is moved off the component. This callback is only fired when the pointer leaves the component.

    For more information about React and "events", check the React documentation

    Arguments

    Default value

  11. onRef

    (Optional)

    Type: Function

    A callback that is called whenever a component's ref changes.

    Use this callback to get a ref to (the domNode of) a component. There shouldn't be many usecases for using this prop yourself, but you might have to implement it with a given argument from a render callback somewhere.

    For more information about React and "refs", check the React documentation

    Arguments

    Returns

    Default value

  12. tooltipContent

    (Optional)

    Type: String | ReactElement

    The content of the tooltip that is displayed when hovering over the whole component.

    • string: the textual content of the tooltip

    • ReactElement: a React Element (instance of a React Component, usually created with JSX)

    Default value