Honeycomb

dropdown-item

Props

Prop nameTypeDefaultDescription
dividerboolean | undefinedfalse

Shows a divider between the items.

extraClassesstring | undefined

Injection in class name.

childrenReactNode

The rendered text.

activeboolean | undefinedfalse

Makes the item active

since v. 2.2.0
InlineIconInlineIconProp | undefined

Icon to display next to the item text. ``` InlineIcon | { regular: InlineIcon, active: InlineIcon } ```

since v. 2.5.0
Elem"span" | "div" | "button" | "a" | undefined

Override the default element to render the content.

hrefstring | undefined

The url to link to.

RouterLinkHCRouterLink | undefined

custom link RouterLink, e.g. if you use ReactRouter or similar library

This is a specialized component to be used in the Dropdown.

Check the Dropdown component for more examples.

Here is an example of many DropdownItem variations you can achieve:

import { Dropdown, DropdownItem, Button } from '@flixbus/honeycomb-react';
import { Icon, IconBeer, IconBeerSolid } from '@flixbus/honeycomb-icons-react';
import { BrowserRouter, NavLink } from 'react-router-dom';

const linkArray = [
  <DropdownItem key="1" href="/active-link" InlineIcon={{ regular: IconBeer, active: IconBeerSolid }} active>Active link</DropdownItem>,
  <DropdownItem key="2" href="/link" InlineIcon={{ regular: IconBeer, active: IconBeerSolid }}>Link</DropdownItem>,
  <DropdownItem key="3" Elem="button" onClick={() => console.log('click!')}>Button</DropdownItem>,
  <DropdownItem key="4" divider />,
  <DropdownItem key="5">Text</DropdownItem>,
  <DropdownItem key="6" RouterLink={NavLink} to="/route" InlineIcon={IconBeer}>Router link</DropdownItem>,
];

<div style={{ textAlign: 'center' }}>
  <BrowserRouter>
    <Dropdown active links={linkArray}>
      <Button appearance="primary">Dropdown Item Options</Button>
    </Dropdown>
  </BrowserRouter>
</div>