vdux-dropdown
v1.0.1
Published
Stateful wrapper around vdux-ui's presentational Dropdown component
Downloads
4
Readme
dropdown
Stateful wrapper around vdux-ui's presentational Dropdown and DropdownMenu components.
Installation
$ npm install vdux-dropdown
Usage
Use this to show menus when a button is clicked:
import Dropdown from 'vdux-dropdown'
import {Icon} from 'vdux-ui'
function OptionsMenu () {
return (
<Dropdown btn={<Icon name='settings' />}>
<li onClick={changeUsername}>Change username</li>
<li onClick={changePassword}>Change password</li>
</Dropdown>
)
}
API - props
btn
- Function|VNode - The button that opens the dropdown. If it's a vnode, it will open on click. If it's a function, it will receive{toggle, close}
and should return a vnode (and click handling must be setup manually if you want it).right
- Anchor the dropdown to the right side of its containertop
- Align it with the top edge of the containerref
- If you need to access the API of the dropdown, you can specify thisref
property as a function, and it will provide you with an object containing{toggle, close}
functions so that you can call into the dropdown from outside if you need.
License
MIT