React component that is magnifiable like the Mac OS X dock.
npm install react-osx-dock
React component that is magnifiable like the Mac OS X dock.
Works in any Web browser that supports CSS grid and flexbox layout.
View a demo here.
Install the package with NPM:
``sh`
npm install react-osx-dock
Example:
`jsx
import { Dock } from 'react-osx-dock';
{['A', 'B', 'C', 'D', 'E', 'F', 'G'].map((letter) => (
className="letter"
src={${letter}.png}
onClick={() => console.log(letter)}
key={letter}
/>
))}
`
The Dock component has the following props:
| Name | Description | Type | Required |
| --------------------- | ------------------------------------------------------------------- | --------------------------------------------------- | -------------------------------- |
| itemWidth | The default (i.e. unmagnified) width of dock items in pixels. | number | yes |magnification
| | The % amount of dock item magnification produced on mouse-over. | number | yes |magnifyDirection
| | The vertical direction that dock items grow when magnified. | string enum "up"
(, "down", "center") | yes |className
| | The dock's CSS class. | string | no undefined
default: |backgroundClassName
| | The dock background's CSS class. | string | no undefined
default: |debug
| | Whether to render dock bounding boxes or not. Useful for debugging! | boolean | no false
default: |
Any children provided to the Dock` component will be considered "dock items" and wrapped accordingly to facilitate the magnification behavior.
The demo website uses a couple of free icon packs from FlatIcon:
- Social icons designed by Bogdan Rosu.
- Pokémon icons designed by Roundicons Freebies.
Thanks!