border-beam 1.0.1 → 1.1.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/README.md +41 -11
- package/dist/index.cjs.js +337 -102
- package/dist/index.d.ts +21 -7
- package/dist/index.es.js +855 -295
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# border-beam
|
|
2
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.
|
|
3
|
+
Animated border beam effect for React. A lightweight component that adds a traveling or breathing glow animation around any element — cards, buttons, inputs, or search bars.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -26,9 +26,11 @@ function App() {
|
|
|
26
26
|
|
|
27
27
|
The component wraps your content and overlays the animated beam effect. It auto-detects the `border-radius` of the first child element.
|
|
28
28
|
|
|
29
|
-
##
|
|
29
|
+
## Types
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
Built-in presets control the glow style and motion. They fall into two families:
|
|
32
|
+
|
|
33
|
+
### Rotate (traveling beam)
|
|
32
34
|
|
|
33
35
|
```tsx
|
|
34
36
|
<BorderBeam size="md"> {/* Full border glow (default) */}
|
|
@@ -44,6 +46,33 @@ Three built-in size presets control the glow intensity and animation style:
|
|
|
44
46
|
</BorderBeam>
|
|
45
47
|
```
|
|
46
48
|
|
|
49
|
+
### Pulse (breathing glow, no rotation)
|
|
50
|
+
|
|
51
|
+
```tsx
|
|
52
|
+
<BorderBeam size="pulse-inner"> {/* Contained breathing border glow */}
|
|
53
|
+
<Card />
|
|
54
|
+
</BorderBeam>
|
|
55
|
+
|
|
56
|
+
<BorderBeam size="pulse-outside"> {/* Outward-blooming halo around the element */}
|
|
57
|
+
<Card />
|
|
58
|
+
</BorderBeam>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Both pulse types support all color variants, `strength`, `theme`, and the breathe
|
|
62
|
+
speed via `duration` (defaults to `2.3`).
|
|
63
|
+
|
|
64
|
+
> **`pulse-outside` requires an opaque wrapped child.** The colorful core and halo
|
|
65
|
+
> render *behind* your content (`z-index: -1`) and bloom outward, so only the part
|
|
66
|
+
> that spills beyond the element shows. If your child is transparent, the inner glow
|
|
67
|
+
> will show through. The wrapper uses `overflow: visible`, so make sure the
|
|
68
|
+
> surrounding layout has room (or `overflow: visible`) for the halo to spill.
|
|
69
|
+
|
|
70
|
+
> **`pulse-outside` relies on the wrapped element's own 1px border as the idle
|
|
71
|
+
> hairline.** It does not paint its own hairline by default, so the colored stroke
|
|
72
|
+
> rides directly on top of your element's existing edge instead of doubling it. If
|
|
73
|
+
> your child has no border, add a subtle 1px border (or `box-shadow: inset 0 0 0 1px`)
|
|
74
|
+
> so the edge stays defined while the beam is faded out.
|
|
75
|
+
|
|
47
76
|
## Color variants
|
|
48
77
|
|
|
49
78
|
Four color palettes are available:
|
|
@@ -96,14 +125,14 @@ const [active, setActive] = useState(true);
|
|
|
96
125
|
| Prop | Type | Default | Description |
|
|
97
126
|
|------|------|---------|-------------|
|
|
98
127
|
| `children` | `ReactNode` | — | Content to wrap |
|
|
99
|
-
| `size` | `'sm' \| 'md' \| 'line'` | `'md'` | Size/type preset |
|
|
128
|
+
| `size` | `'sm' \| 'md' \| 'line' \| 'pulse-outside' \| 'pulse-inner'` | `'md'` | Size/type preset |
|
|
100
129
|
| `colorVariant` | `'colorful' \| 'mono' \| 'ocean' \| 'sunset'` | `'colorful'` | Color palette |
|
|
101
130
|
| `theme` | `'dark' \| 'light' \| 'auto'` | `'dark'` | Background adaptation |
|
|
102
131
|
| `strength` | `number` | `1` | Effect opacity (0–1), only affects the beam layers |
|
|
103
|
-
| `duration` | `number` | `1.96` / `2.
|
|
132
|
+
| `duration` | `number` | `1.96` / `3.1` / `2.3` | Animation cycle duration in seconds (rotate / line / pulse) |
|
|
104
133
|
| `active` | `boolean` | `true` | Whether the animation is playing |
|
|
105
134
|
| `borderRadius` | `number` | auto-detected | Custom border radius in px |
|
|
106
|
-
| `brightness` | `number` | `1.3` | Glow brightness multiplier |
|
|
135
|
+
| `brightness` | `number` | per-type (`1.3`) | Glow brightness multiplier; falls back to the type's preset default |
|
|
107
136
|
| `saturation` | `number` | `1.2` | Glow saturation multiplier |
|
|
108
137
|
| `hueRange` | `number` | `30` | Hue rotation range in degrees |
|
|
109
138
|
| `staticColors` | `boolean` | `false` | Disable hue-shift animation |
|
|
@@ -118,11 +147,11 @@ All standard `HTMLDivElement` attributes are also forwarded to the wrapper.
|
|
|
118
147
|
|
|
119
148
|
`BorderBeam` renders a wrapper `<div>` with:
|
|
120
149
|
|
|
121
|
-
- **`::after`** — the beam stroke (conic gradient masked to the border)
|
|
122
|
-
- **`::before`** — inner glow layer
|
|
150
|
+
- **`::after`** — the beam stroke (rotate: conic gradient masked to the border; pulse: the colored perimeter ring / hairline)
|
|
151
|
+
- **`::before`** — inner glow layer (pulse-outside pushes this outward behind the content)
|
|
123
152
|
- **`[data-beam-bloom]`** — outer bloom/glow child div
|
|
124
153
|
|
|
125
|
-
All effect layers are absolutely positioned and use `pointer-events: none`, so they never interfere with your content.
|
|
154
|
+
All effect layers are absolutely positioned and use `pointer-events: none`, so they never interfere with your content. The rotate and line types animate via CSS `@property` keyframes for smooth GPU-accelerated transitions; because the keyframes also declare explicit `0% / 50% / 100%` stops, browsers without `@property` support degrade gracefully (stepped instead of interpolated motion) rather than breaking. The pulse types drive their slow breathing from a single shared, frame-rate-capped (~30fps) `requestAnimationFrame` loop that writes plain CSS custom properties — so the breathing works even without `@property` support, repaints less often, and automatically pauses when the instance is inactive, offscreen, or the user prefers reduced motion. The pulse types also isolate their stacking context, cap blur radii, and hint `will-change` on the animated layers for performance.
|
|
126
155
|
|
|
127
156
|
## Project structure
|
|
128
157
|
|
|
@@ -132,7 +161,8 @@ border-beam/
|
|
|
132
161
|
│ ├── index.ts # Public exports
|
|
133
162
|
│ ├── BorderBeam.tsx # React component
|
|
134
163
|
│ ├── types.ts # TypeScript type definitions
|
|
135
|
-
│
|
|
164
|
+
│ ├── styles.ts # CSS generation engine
|
|
165
|
+
│ └── pulseDriver.ts # Shared rAF loop driving the pulse breathing
|
|
136
166
|
├── demo/ # Vite + React demo site
|
|
137
167
|
├── dist/ # Built output (ESM + CJS + types)
|
|
138
168
|
├── package.json
|
|
@@ -147,7 +177,7 @@ border-beam/
|
|
|
147
177
|
|
|
148
178
|
## Accessibility
|
|
149
179
|
|
|
150
|
-
The effect layers are purely decorative and use `pointer-events: none`. They do not affect keyboard navigation or screen readers. The
|
|
180
|
+
The effect layers are purely decorative and use `pointer-events: none`. They do not affect keyboard navigation or screen readers. The pulse types ship a built-in `prefers-reduced-motion: reduce` block that disables their animations; the rotate types respect `prefers-reduced-motion` when implemented by the consumer.
|
|
151
181
|
|
|
152
182
|
## License
|
|
153
183
|
|