<Meta title="Inputs/Dropdown/Guide" />

# FFWD Dropdown

A classic **Dropdown** implementation, including essential variants for sort of uses.

# Usage

1. As the example below, create a dropdown list based on `DropdownItem<T>[]`:
```
const fruitIconList: DropdownItem<Fruit>[] = [{
        reactKey: 'apple',
        text: 'apple',
        value: Fruit.Apple,
        iconName: 'customise'
    }, {
        reactKey: 'orange',
        text: 'orange',
        value: Fruit.Orange,
        iconName: 'ghost'
    }, {
        reactKey: 'banana',
        text: 'banana',
        value: Fruit.Banana,
        iconName: 'email'
    }
];
```

2. Implement the required event handler on **Dropdown** component:
```
const [fruit, setFruit] = useState<Fruit | undefined>(args.placeholder ? undefined : Fruit.Apple);

function findActiveItem(): DropdownItem<Fruit> | undefined {
    return (args.list as DropdownItem<Fruit>[]).find((elm) => elm.value === fruit);
}

function changeHandler(item: DropdownItem<Fruit>) {
    setFruit(item.value);
}

return <Dropdown
    {...args}
    list={args.list}
    activeItem={findActiveItem()}
    onActiveItemChange={changeHandler}
/>
```
