|
| 1 | +@# ArrayDefault |
| 2 | + |
| 3 | +Navbars present useful navigation controls at the top of an application. |
| 4 | + |
| 5 | +@reactExample ArrayDefaultExample |
| 6 | + |
| 7 | +@### Fixed to viewport top |
| 8 | + |
| 9 | +Enable the `fixedToTop` prop to attach a navbar to the top of the viewport using |
| 10 | +`position: fixed; top: 0;`. This is so-called "sticky" behavior: the navbar |
| 11 | +stays at the top of the screen as the user scrolls through the document. |
| 12 | + |
| 13 | +This modifier is not illustrated here because it breaks the document flow. |
| 14 | + |
| 15 | +<div class="@ns-callout @ns-intent-danger @ns-icon-error"> |
| 16 | + <h4 class="@ns-heading">Body padding required</h4> |
| 17 | + The fixed navbar will lie on top of your other content unless you add padding to the top of the |
| 18 | + `<body>` element equal to the height of the navbar. Use the `$pt-navbar-height` Sass variable. |
| 19 | +</div> |
| 20 | + |
| 21 | +@### Fixed width |
| 22 | + |
| 23 | +If your application is inside a fixed-width container (instead of spanning the |
| 24 | +entire viewport), you can align the navbar to match by wrap your navbar groups |
| 25 | +in an element with your desired `width` and `margin: 0 auto;` to horizontally |
| 26 | +center it. |
| 27 | + |
| 28 | +@css navbar-container |
| 29 | + |
| 30 | +@## Props |
| 31 | + |
| 32 | +The `Navbar` API includes four stateless React components: |
| 33 | + |
| 34 | +* `Navbar` |
| 35 | +* `NavbarGroup` (aliased as `Navbar.Group`) |
| 36 | +* `NavbarHeading` (aliased as `Navbar.Heading`) |
| 37 | +* `NavbarDivider` (aliased as `Navbar.Divider`) |
| 38 | + |
| 39 | +These components are simple containers for their children. Each of them supports |
| 40 | +the full range of HTML `<div>` props. |
| 41 | + |
| 42 | +```tsx |
| 43 | +<Navbar> |
| 44 | + <Navbar.Group align={Alignment.LEFT}> |
| 45 | + <Navbar.Heading>Blueprint</Navbar.Heading> |
| 46 | + <Navbar.Divider /> |
| 47 | + <Button className="@ns-minimal" icon="home" text="Home" /> |
| 48 | + <Button className="@ns-minimal" icon="document" text="Files" /> |
| 49 | + </Navbar.Group> |
| 50 | +</Navbar> |
| 51 | +``` |
| 52 | + |
| 53 | +@interface INavbarProps |
| 54 | + |
| 55 | +@interface INavbarGroupProps |
| 56 | + |
| 57 | +@interface INavbarHeadingProps |
| 58 | + |
| 59 | +@interface INavbarDividerProps |
| 60 | + |
| 61 | +@## CSS |
| 62 | + |
| 63 | +Use the following classes to construct a navbar: |
| 64 | + |
| 65 | +* `nav.@ns-navbar` – The parent element. Use a `<nav>` element for accessibility. |
| 66 | +* `.@ns-navbar-group.@ns-align-(left|right)` – Left- or right-aligned group. |
| 67 | +* `.@ns-navbar-heading` – Larger text for your application title. |
| 68 | +* `.@ns-navbar-divider` – Thin vertical line that can be placed between groups of elements. |
| 69 | + |
| 70 | +@css navbar |
0 commit comments