2.0.0 • Published 2 months ago

react-osx-dock v2.0.0

Weekly downloads
31
License
MIT
Repository
github
Last release
2 months ago

react-osx-dock npm version

npm.io

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.

Installation

Install the package with NPM:

npm install react-osx-dock

Usage

Example:

import { Dock } from 'react-osx-dock';

<Dock itemWidth={50} magnification={2} magnifyDirection="up">
  {['A', 'B', 'C', 'D', 'E', 'F', 'G'].map((letter) => (
    <img
      className="letter"
      src={`${letter}.png`}
      onClick={() => console.log(letter)}
      key={letter}
    />
  ))}
</Dock>

API

The Dock component has the following props:

NameDescriptionTypeRequired
itemWidthThe default (i.e. unmagnified) width of dock items in pixels.numberyes
magnificationThe % amount of dock item magnification produced on mouse-over.numberyes
magnifyDirectionThe vertical direction that dock items grow when magnified.string enum ("up", "down", "center")yes
classNameThe dock's CSS class.stringno default: undefined
backgroundClassNameThe dock background's CSS class.stringno default: undefined
debugWhether to render dock bounding boxes or not. Useful for debugging!booleanno default: false

Any children provided to the Dock component will be considered "dock items" and wrapped accordingly to facilitate the magnification behavior.

Credits

The demo website uses a couple of free icon packs from FlatIcon:

Thanks!