border-beam 1.0.1
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 +154 -0
- package/dist/index.cjs.js +663 -0
- package/dist/index.d.ts +169 -0
- package/dist/index.es.js +1365 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jakub Antalik
|
|
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
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# border-beam
|
|
2
|
+
|
|
3
|
+
Animated border beam effect for React. A lightweight component that adds a traveling glow animation around any element — cards, buttons, inputs, or search bars.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install border-beam
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { BorderBeam } from 'border-beam';
|
|
15
|
+
|
|
16
|
+
function App() {
|
|
17
|
+
return (
|
|
18
|
+
<BorderBeam>
|
|
19
|
+
<div style={{ padding: 32, borderRadius: 16, background: '#1d1d1d' }}>
|
|
20
|
+
Your content here
|
|
21
|
+
</div>
|
|
22
|
+
</BorderBeam>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The component wraps your content and overlays the animated beam effect. It auto-detects the `border-radius` of the first child element.
|
|
28
|
+
|
|
29
|
+
## Sizes
|
|
30
|
+
|
|
31
|
+
Three built-in size presets control the glow intensity and animation style:
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
<BorderBeam size="md"> {/* Full border glow (default) */}
|
|
35
|
+
<Card />
|
|
36
|
+
</BorderBeam>
|
|
37
|
+
|
|
38
|
+
<BorderBeam size="sm"> {/* Compact glow for small elements */}
|
|
39
|
+
<IconButton />
|
|
40
|
+
</BorderBeam>
|
|
41
|
+
|
|
42
|
+
<BorderBeam size="line"> {/* Bottom-only traveling glow */}
|
|
43
|
+
<SearchBar />
|
|
44
|
+
</BorderBeam>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Color variants
|
|
48
|
+
|
|
49
|
+
Four color palettes are available:
|
|
50
|
+
|
|
51
|
+
```tsx
|
|
52
|
+
<BorderBeam colorVariant="colorful" /> {/* Rainbow spectrum (default) */}
|
|
53
|
+
<BorderBeam colorVariant="mono" /> {/* Grayscale */}
|
|
54
|
+
<BorderBeam colorVariant="ocean" /> {/* Blue-purple tones */}
|
|
55
|
+
<BorderBeam colorVariant="sunset" /> {/* Orange-yellow-red tones */}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
All variants except `mono` animate through a hue-shift cycle.
|
|
59
|
+
|
|
60
|
+
## Theme
|
|
61
|
+
|
|
62
|
+
Adapts beam colors for dark or light backgrounds:
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
<BorderBeam theme="dark" /> {/* Dark background (default) */}
|
|
66
|
+
<BorderBeam theme="light" /> {/* Light background */}
|
|
67
|
+
<BorderBeam theme="auto" /> {/* Detects system preference */}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Strength
|
|
71
|
+
|
|
72
|
+
Control the overall intensity of the effect without affecting the wrapped content:
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
<BorderBeam strength={0.7}> {/* 70% intensity */}
|
|
76
|
+
<Card />
|
|
77
|
+
</BorderBeam>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
`strength` accepts a value from `0` (invisible) to `1` (full intensity, default).
|
|
81
|
+
|
|
82
|
+
## Play / pause
|
|
83
|
+
|
|
84
|
+
Toggle the animation on and off with smooth fade transitions:
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
const [active, setActive] = useState(true);
|
|
88
|
+
|
|
89
|
+
<BorderBeam active={active} onDeactivate={() => console.log('faded out')}>
|
|
90
|
+
<Card />
|
|
91
|
+
</BorderBeam>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Props
|
|
95
|
+
|
|
96
|
+
| Prop | Type | Default | Description |
|
|
97
|
+
|------|------|---------|-------------|
|
|
98
|
+
| `children` | `ReactNode` | — | Content to wrap |
|
|
99
|
+
| `size` | `'sm' \| 'md' \| 'line'` | `'md'` | Size/type preset |
|
|
100
|
+
| `colorVariant` | `'colorful' \| 'mono' \| 'ocean' \| 'sunset'` | `'colorful'` | Color palette |
|
|
101
|
+
| `theme` | `'dark' \| 'light' \| 'auto'` | `'dark'` | Background adaptation |
|
|
102
|
+
| `strength` | `number` | `1` | Effect opacity (0–1), only affects the beam layers |
|
|
103
|
+
| `duration` | `number` | `1.96` / `2.4` | Animation cycle duration in seconds |
|
|
104
|
+
| `active` | `boolean` | `true` | Whether the animation is playing |
|
|
105
|
+
| `borderRadius` | `number` | auto-detected | Custom border radius in px |
|
|
106
|
+
| `brightness` | `number` | `1.3` | Glow brightness multiplier |
|
|
107
|
+
| `saturation` | `number` | `1.2` | Glow saturation multiplier |
|
|
108
|
+
| `hueRange` | `number` | `30` | Hue rotation range in degrees |
|
|
109
|
+
| `staticColors` | `boolean` | `false` | Disable hue-shift animation |
|
|
110
|
+
| `className` | `string` | — | Additional class on the wrapper |
|
|
111
|
+
| `style` | `CSSProperties` | — | Additional inline styles on the wrapper |
|
|
112
|
+
| `onActivate` | `() => void` | — | Called when fade-in completes |
|
|
113
|
+
| `onDeactivate` | `() => void` | — | Called when fade-out completes |
|
|
114
|
+
|
|
115
|
+
All standard `HTMLDivElement` attributes are also forwarded to the wrapper.
|
|
116
|
+
|
|
117
|
+
## How it works
|
|
118
|
+
|
|
119
|
+
`BorderBeam` renders a wrapper `<div>` with:
|
|
120
|
+
|
|
121
|
+
- **`::after`** — the beam stroke (conic gradient masked to the border)
|
|
122
|
+
- **`::before`** — inner glow layer
|
|
123
|
+
- **`[data-beam-bloom]`** — outer bloom/glow child div
|
|
124
|
+
|
|
125
|
+
All effect layers are absolutely positioned and use `pointer-events: none`, so they never interfere with your content. Animations use CSS `@property` for smooth GPU-accelerated transitions.
|
|
126
|
+
|
|
127
|
+
## Project structure
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
border-beam/
|
|
131
|
+
├── src/
|
|
132
|
+
│ ├── index.ts # Public exports
|
|
133
|
+
│ ├── BorderBeam.tsx # React component
|
|
134
|
+
│ ├── types.ts # TypeScript type definitions
|
|
135
|
+
│ └── styles.ts # CSS generation engine
|
|
136
|
+
├── demo/ # Vite + React demo site
|
|
137
|
+
├── dist/ # Built output (ESM + CJS + types)
|
|
138
|
+
├── package.json
|
|
139
|
+
├── LICENSE
|
|
140
|
+
└── README.md
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Requirements
|
|
144
|
+
|
|
145
|
+
- React 18+
|
|
146
|
+
- Modern browser with CSS `@property` support (Chrome 85+, Safari 15.4+, Firefox 128+)
|
|
147
|
+
|
|
148
|
+
## Accessibility
|
|
149
|
+
|
|
150
|
+
The effect layers are purely decorative and use `pointer-events: none`. They do not affect keyboard navigation or screen readers. The component respects `prefers-reduced-motion` when implemented by the consumer.
|
|
151
|
+
|
|
152
|
+
## License
|
|
153
|
+
|
|
154
|
+
[MIT](./LICENSE)
|