notchbar 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +192 -2
- package/dist/index.cjs +585 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +146 -0
- package/dist/index.d.ts +146 -0
- package/dist/index.js +563 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.css +510 -0
- package/package.json +82 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 dhruxvsharma
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,193 @@
|
|
|
1
|
-
#
|
|
1
|
+
# notchbar
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**A React navbar that hangs from the top of your page.**
|
|
4
|
+
|
|
5
|
+
It sits like paper while you read, turns to liquid glass once you scroll, and opens one menu panel that reshapes itself as you move between menus.
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/notchbar)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
|
|
10
|
+
**[See it live →](https://notchbar-kappa.vercel.app/)**
|
|
11
|
+
|
|
12
|
+

|
|
13
|
+
|
|
14
|
+
## Why you might like it
|
|
15
|
+
|
|
16
|
+
- **It feels physical.** The tab squashes and stretches as it springs, like it has weight.
|
|
17
|
+
- **Glass that forms, not swaps.** The paper dissolves, a glint sweeps across, and in Chrome the edges bend what passes under them.
|
|
18
|
+
- **One panel for every menu.** It resizes between menus and slides in from the side you came from.
|
|
19
|
+
- **Small touches.** Hand-drawn hover strokes, a breathing dot on the button, "New" circled in marker.
|
|
20
|
+
- **Works for everyone.** Real links and buttons, keyboard support, Escape to close, a phone menu below 768px, and plain fades when someone asks for reduced motion.
|
|
21
|
+
|
|
22
|
+

|
|
23
|
+
|
|
24
|
+
## Get started
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm i notchbar motion
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
import { Notchbar } from "notchbar";
|
|
32
|
+
import "notchbar/styles.css";
|
|
33
|
+
|
|
34
|
+
export function Header() {
|
|
35
|
+
return (
|
|
36
|
+
<Notchbar
|
|
37
|
+
brand={{ name: "Acme" }}
|
|
38
|
+
items={[
|
|
39
|
+
{ label: "Pricing", href: "/pricing" },
|
|
40
|
+
{ label: "Docs", href: "/docs" },
|
|
41
|
+
]}
|
|
42
|
+
cta={{ label: "Sign up", href: "/signup" }}
|
|
43
|
+
/>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
That's it. The nav is fixed to the top, so leave about 80px of space above your content.
|
|
49
|
+
|
|
50
|
+
Needs React 18 or newer and [motion](https://motion.dev).
|
|
51
|
+
|
|
52
|
+
## Add a menu
|
|
53
|
+
|
|
54
|
+
Give an item a `panel` instead of an `href`, and build the panel from ready-made blocks:
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
import { Notchbar, PanelHeader, PanelRows, NewMark } from "notchbar";
|
|
58
|
+
|
|
59
|
+
const items = [
|
|
60
|
+
{
|
|
61
|
+
label: "Product",
|
|
62
|
+
panel: () => (
|
|
63
|
+
<>
|
|
64
|
+
<PanelHeader title="Product" />
|
|
65
|
+
<PanelRows
|
|
66
|
+
rows={[
|
|
67
|
+
{ href: "/boards", title: "Boards", meta: "Plan" },
|
|
68
|
+
{ href: "/docs", title: "Docs", badge: <NewMark /> },
|
|
69
|
+
]}
|
|
70
|
+
/>
|
|
71
|
+
</>
|
|
72
|
+
),
|
|
73
|
+
// what this menu shows in the phone menu
|
|
74
|
+
mobile: [
|
|
75
|
+
{ label: "Boards", href: "/boards" },
|
|
76
|
+
{ label: "Docs", href: "/docs" },
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
{ label: "Pricing", href: "/pricing" },
|
|
80
|
+
];
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
A panel can hold anything you like. The blocks just save you the styling:
|
|
84
|
+
|
|
85
|
+
| Block | What it is |
|
|
86
|
+
|---|---|
|
|
87
|
+
| `PanelHeader` | A small heading row, with an optional note on the right |
|
|
88
|
+
| `PanelRows` | One link per row, with an arrow that slides in on hover |
|
|
89
|
+
| `PanelCards` | Links with an icon, a title and a line of text |
|
|
90
|
+
| `PanelGrid` | A compact two-column grid of short links |
|
|
91
|
+
| `PanelSplit` | Two columns side by side |
|
|
92
|
+
| `PanelFooter` and `PanelLink` | A quiet strip along the bottom, with an underlined link |
|
|
93
|
+
| `NewMark` | "New", circled in marker |
|
|
94
|
+
| `usePanel()` | Gives you `close()` for your own panel content |
|
|
95
|
+
|
|
96
|
+
Links whose `href` starts with `#` underline themselves while that section is on screen.
|
|
97
|
+
|
|
98
|
+
## Next.js and React Router
|
|
99
|
+
|
|
100
|
+
Pass your router's link so navigation stays client-side:
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
import Link from "next/link";
|
|
104
|
+
|
|
105
|
+
<Notchbar linkComponent={Link} brand={{ name: "Acme" }} items={items} />;
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
The build already includes `"use client"`. For React Router, wrap its `Link` so it reads `href`:
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
const RouterLink = ({ href, ...rest }) => <Link to={href} {...rest} />;
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Make it yours
|
|
115
|
+
|
|
116
|
+
One prop sets your colour. It tints the hover strokes, the button's dot and every "New":
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
<Notchbar accent="#2f6bff" ... />
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Everything else is plain CSS variables:
|
|
123
|
+
|
|
124
|
+
```css
|
|
125
|
+
.nb {
|
|
126
|
+
--nb-ink: #111; /* text */
|
|
127
|
+
--nb-muted: #8f8f8a; /* secondary text */
|
|
128
|
+
--nb-paper: #efefec; /* the tab at the top of the page */
|
|
129
|
+
--nb-glass: rgba(255, 255, 255, 0.42); /* the glass tint */
|
|
130
|
+
--nb-font-marker: "Gochi Hand", cursive; /* for the "New" marks */
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
The nav uses your page's font. "New" marks look best with a handwriting font like [Gochi Hand](https://fonts.google.com/specimen/Gochi+Hand).
|
|
135
|
+
|
|
136
|
+
## Props
|
|
137
|
+
|
|
138
|
+
| Prop | Default | What it does |
|
|
139
|
+
|---|---|---|
|
|
140
|
+
| `brand` | required | `{ name, href?, mark?, label? }`. The logo on the left. `mark` swaps in your own logo. |
|
|
141
|
+
| `items` | required | The links and menus in the middle. |
|
|
142
|
+
| `cta` | none | `{ label, href }`. The button on the right. |
|
|
143
|
+
| `accent` | `#e5484d` | The marker colour. |
|
|
144
|
+
| `state` | `"auto"` | `"auto"` follows the scroll. `"paper"` or `"glass"` pins one look. |
|
|
145
|
+
| `maxWidth` | `1024` | How wide the paper tab gets, in px. |
|
|
146
|
+
| `compactAt` | `56` | How far you scroll (px) before it turns to glass. |
|
|
147
|
+
| `expandAt` | `24` | How close to the top (px) before it stretches back. |
|
|
148
|
+
| `linkComponent` | `"a"` | Your router's link. |
|
|
149
|
+
| `className` | none | Added to the outer `<header>`. |
|
|
150
|
+
|
|
151
|
+
<details>
|
|
152
|
+
<summary>Item types</summary>
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
type NavLinkItem = { label: string; href: string };
|
|
156
|
+
|
|
157
|
+
type NavMenu = {
|
|
158
|
+
label: string;
|
|
159
|
+
panel: (ctx: { close: () => void; reduced: boolean }) => ReactNode;
|
|
160
|
+
width?: string; // the panel's width, any CSS length. Default 36rem
|
|
161
|
+
mobile?: MobileLink[]; // what this menu lists in the phone menu
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
type MobileLink = { label: string; href: string; meta?: string; badge?: ReactNode };
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
</details>
|
|
168
|
+
|
|
169
|
+
<details>
|
|
170
|
+
<summary>Browser support</summary>
|
|
171
|
+
|
|
172
|
+
Everything works in every modern browser. The bending glass uses an SVG filter that only Chromium supports, so Safari and Firefox get clean frosted glass instead. With *reduce transparency* turned on, the glass becomes solid.
|
|
173
|
+
|
|
174
|
+
</details>
|
|
175
|
+
|
|
176
|
+
## Run the demo locally
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
git clone https://github.com/dhruxvsharma/notchbar
|
|
180
|
+
cd notchbar
|
|
181
|
+
npm install
|
|
182
|
+
npm run demo
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Made by
|
|
186
|
+
|
|
187
|
+
**Dhruv Sharma** · [X](https://x.com/Dhruxvsharma) · [LinkedIn](https://www.linkedin.com/in/dhruxvsharma/) · [Instagram](https://www.instagram.com/dhruxvsharma/) · [GitHub](https://github.com/dhruxvsharma)
|
|
188
|
+
|
|
189
|
+
If notchbar ends up on your site, I'd love to see it. Tag me on X, or open an issue with a link.
|
|
190
|
+
|
|
191
|
+
## License
|
|
192
|
+
|
|
193
|
+
MIT © Dhruv Sharma
|