Backpack horizontal nav component.
Check the main Readme for a complete installation guide.
import { Component } from 'react';
import BpkHorizontalNav, { BpkHorizontalNavItem } from '@skyscanner/backpack-web/bpk-component-horizontal-nav';
export default class App extends Component {
constructor() {
super();
this.state = {
selected: 'flights',
};
}
onClick = (e) => {
this.setState({
selected: e.target.name,
});
}
render() {
return (
<BpkHorizontalNav>
<BpkHorizontalNavItem
name="flights"
selected={this.state.selected === 'flights'}
onClick={this.onClick}
>
Flights
</BpkHorizontalNavItem>
<BpkHorizontalNavItem
name="hotels"
selected={this.state.selected === 'hotels'}
onClick={this.onClick}
>
Hotels
</BpkHorizontalNavItem>
<BpkHorizontalNavItem
name="car-hire"
selected={this.state.selected === 'car-hire'}
onClick={this.onClick}
>
Car hire
</BpkHorizontalNavItem>
</BpkHorizontalNav>
);
}
};
Check out the full list of props on Skyscanner's design system documentation website.