Shards React
DocumentationUsing the Navbar
component you can create powerful and responsive navigation headers.
import React from "react";
import { faSearch } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import {
Navbar,
NavbarToggler,
NavbarBrand,
Nav,
NavItem,
NavLink,
Dropdown,
DropdownToggle,
DropdownMenu,
DropdownItem,
InputGroup,
InputGroupAddon,
InputGroupText,
FormInput,
Collapse
} from "shards-react";
export default class NavExample extends React.Component {
constructor(props) {
super(props);
this.toggleDropdown = this.toggleDropdown.bind(this);
this.toggleNavbar = this.toggleNavbar.bind(this);
this.state = {
dropdownOpen: false,
collapseOpen: false
};
}
toggleDropdown() {
this.setState({
...this.state,
...{
dropdownOpen: !this.state.dropdownOpen
}
});
}
toggleNavbar() {
this.setState({
...this.state,
...{
collapseOpen: !this.state.collapseOpen
}
});
}
render() {
return (
<Navbar type="dark" theme="primary" expand="md">
<NavbarBrand href="#">Shards React</NavbarBrand>
<NavbarToggler onClick={this.toggleNavbar} />
<Collapse open={this.state.collapseOpen} navbar>
<Nav navbar>
<NavItem>
<NavLink active href="#">
Active
</NavLink>
</NavItem>
<NavItem>
<NavLink href="#" disabled>
Disabled
</NavLink>
</NavItem>
<Dropdown
open={this.state.dropdownOpen}
toggle={this.toggleDropdown}
>
<DropdownToggle nav caret>
Dropdown
</DropdownToggle>
<DropdownMenu>
<DropdownItem>Action</DropdownItem>
<DropdownItem>Another action</DropdownItem>
<DropdownItem>Something else here</DropdownItem>
</DropdownMenu>
</Dropdown>
</Nav>
<Nav navbar className="ml-auto">
<InputGroup size="sm" seamless>
<InputGroupAddon type="prepend">
<InputGroupText>
<FontAwesomeIcon icon={faSearch} />
</InputGroupText>
</InputGroupAddon>
<FormInput className="border-0" placeholder="Search..." />
</InputGroup>
</Nav>
</Collapse>
</Navbar>
);
}
}
The following props are available for the Navbar
component.
Prop | Description | Type | Default | Required |
---|---|---|---|---|
full | Whether it is full, or not. | Bool | - | No |
fixed | Whether it is fixed, or not. | String | - | No |
sticky | Whether it is sticky, or not. | String | - | No |
theme | The theme color. | String | - | No |
role | The role attribute. | String | - | No |
className | The class name attribute. | String | - | No |
type | The navbar type. | Enum | - | No |
tag | The component's tag type. | Func String | "nav" | No |
expand | Whether it should expand, or not. | Bool String | false | No |
The following subcomponents are available for the Navbar
component.
Prop | Description | Type | Default | Required |
---|---|---|---|---|
className | The class name. | String | - | No |
tag | The component's tag type. | Func String | "a" | No |
Prop | Description | Type | Default | Required |
---|---|---|---|---|
type | The component's tag type. | String | "button" | No |
className | The class name. | String | - | No |
children | The children nodes. | Node | - | No |
tag | The tag type. | Func String | "button" | No |