Impromptu React Animated Header
A responsive nav header component for React.
Try before you browserify: http://johanneshilden.github.io/impromptu-react-animated-header/
Installation
Npm is the recommended install method.
$ npm install impromptu-react-animated-header
Copy CSS files and icons to a suitable location.
$ cp -r node_modules/impromptu-react-animated-header/css/ node_modules/impromptu-react-animated-header/icons/ .
How to use
- Include the module.
var TopMenu = require('impromptu-react-animated-header').TopMenu;
var MenuItem = require('impromptu-react-animated-header').MenuItem;
var MenuBrand = require('impromptu-react-animated-header').MenuBrand;
- Lay out the menu using the
<TopMenu>
and<MenuItem>
components. An optional<MenuBrand>
can be included prior to the menu items.
<TopMenu>
<MenuBrand>
<a href="#home">Navigation</a>
</MenuBrand>
<MenuItem>
<a href="#home">Home</a>
</MenuItem>
<MenuItem>
<a href="#about">About</a>
</MenuItem>
<MenuItem>
<a href="#configuration">Configuration</a>
</MenuItem>
<MenuItem>
<a href="#contribute">Contribute</a>
</MenuItem>
</TopMenu>
Full working example
In this example, we create the menu component in main.js
.
var React = ;var TopMenu = TopMenu;var MenuItem = MenuItem;var MenuBrand = MenuBrand; var MyMenu = React; React;
Make sure index.html
includes impromptu-header.min.css
.
React Impromptu Animated Header
Build the example, e.g., using Browserify:
$ browserify -t reactify main.js -o bundle.js
Styling
The included stylesheet is pretty rudimentary. Typically, you'd want to, at least, override the default font and align the colors with the rest of your application.
The examples include a more complete themed version of the navbar, using the theme.css stylesheet.
Props
TopMenu
supports a number of props:
Property | Type | Description | Default |
---|---|---|---|
align |
'left' | 'right' | Horizontal alignment of the menu. | 'left' |
brandAlign |
'left' | 'right' | Position of the logo, if one is used. | 'left' |
autoClose |
Boolean | Controls whether the menu should automatically close when an item is clicked. | true |
threshold |
Number | Collapse breakpoint: A viewport width less than this value will cause the navbar to collapse (in pixels). | 769 |
cssTransitions |
Boolean | Apply CSS classes for transitions? (See examples) | false |
animate |
Boolean | Animate opening and closing of the menu in collapsed mode? | true |
duration |
Number | Duration of the anmation, in milliseconds. | 300 |
Contribute
Fork, submit pull requests or report any issues: https://github.com/johanneshilden/impromptu-react-animated-header
License
Impromptu React Animated Header is provided under the BSD License.