# react-top-detecting-navbar

> UI component that detects if you are scrolled to the top of the page

Latest version **1.0.3** (published 2019-09-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-top-detecting-navbar
pnpm add react-top-detecting-navbar
yarn add react-top-detecting-navbar
bun add react-top-detecting-navbar
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2019-09-26 |
| First published | 2019-09-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 14 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | dgillen27 |
| Keywords | react, npm, navbar, dgillen27, top-detecting, ui, page, top |

## Links

- npm: https://www.npmjs.com/package/react-top-detecting-navbar
- Repository: https://github.com/dgillen27/react-top-detecting-navbar
- Homepage: https://github.com/dgillen27/react-top-detecting-navbar#readme
- Issues: https://github.com/dgillen27/react-top-detecting-navbar/issues
- npm.io page: https://npm.io/package/react-top-detecting-navbar

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2019-09-26
- 1.0.2 — 2019-09-26
- 1.0.1 — 2019-09-26

## README

# react-top-detecting-navbar

[![npm (scoped)](https://img.shields.io/npm/v/react-top-detecting-navbar.svg)](https://github.com/dgillen27/react-top-detecting-navbar)

## Installation

```
$ npm install react-top-detecting-navbar
```

## Basic Usage

```js
import TopDetectingNavbar from "react-top-detecting-navbar";

function App() {
  return <TopDetectingNavbar></TopDetectingNavbar>;
}
```

## Default styles

The TopDetectingNavbar may be passed a style object or a base className and topClassName so you can style this component as you would like, **_I highly recommend using the style object or className and topClassName_**. However, if you choose not to pass a style object or className and topClassName, these are your default styles for the component.

```js
const defaultStyle = {
  height: "66px",
  width: "100vw",
  backgroundColor: "grey",
  position: "fixed"
};

const defaultTopStyle = {
  height: "66px",
  width: "100vw",
  backgroundColor: "white",
  position: "fixed"
};
```

The default styles are really just intended to give you a reference point for when you first start working with the package.

## Passing Props

These styles can be overwritten if you pass in props! TopDetectingNavBar accepts six different options as props:

| Prop                   | Prop Type | Purpose                                                                               |
| ---------------------- | --------- | ------------------------------------------------------------------------------------- |
| **className**          | String    | Assign a className to the navbar                                                      |
| **topClassName**       | String    | Assign a className to the navbar when it is at the top of the page                    |
| **height**             | Number    | Assign a height to style of the the navbar in px                                      |
| **width**              | Number    | Assign a width to style of the the navbar in vw                                       |
| **backgroundColor**    | String    | Assign a backgruondColor to the style of the navbar                                   |
| **topBackgroundColor** | String    | Assign a backgruondColor to the style of the navbar when it is at the top of the page |
| **style**              | Object    | Assign a style object to the navbar                                                   |

---

Note: If you are declaring a topClassName, you need to declare a className as well

## Advanced Usage/Passing Props

- If you pass in a style object or className/topClassName, `height`, `width`, `backgroundcolor`, and `topBackgroundColor` will be ignored.
- Passing in a className with no topClassName will give the component the className that you pass it.
- If you have passed a className and topClassName, the component at the top of the page will recieve a className of both, (e.g., `className="hello" topClassName="world"` the component will have a className of `"hello world"`) if you are not at the top of the page, it will only recieve the className of `"hello"`.
- Passing in a style object and className will behave the way you would expect with any other element (i.e., the className will be over-written by any styles that )

---

### Passing in classNames

```js
import TopDetectingNavbar from "react-top-detecting-navbar";

function App() {
  return (
    <TopDetectingNavbar className="hello" topClassName="world">
      <h1>Your content here</h1>
    </TopDetectingNavbar>
  );
}
```

className at the top of the page will be `"hello world"`

className anywhere else on the page will be `"hello"`

---

### Passing in style object

```js
import TopDetectingNavbar from "react-top-detecting-navbar";

function App() {
  return (
    <TopDetectingNavbar
      style={{ backgroundColor: "red", height: "70px", width: "100vw" }}
    >
      <h1>Your content here</h1>
    </TopDetectingNavbar>
  );
}
```

---

### Passing in style props

```js
import TopDetectingNavbar from "react-top-detecting-navbar";

function App() {
  return (
    <TopDetectingNavbar
      height={66}
      width={100}
      backgroundColor="red"
      topBackgroundColor="blue"
    >
      <h1>Your content here</h1>
    </TopDetectingNavbar>
  );
}
```

---

### Template

Template for react npm packages provided by [flexdinesh](https://github.com/flexdinesh/react-npm-package-boilerplate) on github.

## License

react-top-detecting-navbar is MIT licensed

---
_Source: https://npm.io/package/react-top-detecting-navbar · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
