@gfazioli/mantine-border-animate
Mantine component offering five border animation variants (beam, glow, pulse, draw, dash) with a progress-driven border, dashed patterns, hover/focus/in-view triggers and full animation control, perfect for creating dynamic, visually engaging UI elements.
Upgrading from an older major version? See the Upgrade guide for breaking changes and step-by-step migration instructions.
Installation
After installation import package styles at the root of your application:
You can import styles within a layer @layer mantine-border-animate by importing @gfazioli/mantine-border-animate/styles.layer.css file.
Usage
The BorderAnimate component wraps any element to add stunning animated border effects. It's perfect for creating eye-catching UI elements like cards, buttons, input fields, alerts, and more.
Key Features
- Five animation variants - beam, glow, pulse, draw and dash
- Three beam modes -
dot(a traveling dot),wedge(a rotating gradient) orcomet(a head with a tail) - A border that measures -
variant="draw"withprogressturns the border into a progress indicator - Trigger on interaction - animate on hover, on focus, or only while the component is on screen
- Fully customizable - Control colors, duration, size, blur, offset and more
- Works with any element - Wrap buttons, cards, inputs, or any Mantine component
- Performance optimized - Pure CSS and SVG animations, no JavaScript per frame
- Custom color stops - Multi-color gradients with
colorStops - Pause on hover - Pause animations when hovering with
pauseOnHover - Accessible - Honors
prefers-reduced-motionthrough the Mantine theme
Simply wrap your content with BorderAnimate and customize it using props:
Animate Border
This is an example of BorderAnimate component
Controlled
You can control the border animation using the show prop.
This is a title
This is a paragraph inside the BorderAnimate component.
Animated
You can also control the border animation using the animate prop. If animate is set to true, the border will animate continuously. If animate is set to false, the border will be static. The progress prop then decides where along the perimeter the effect sits, as a percentage from 0 to 100.
This is a title
This is a paragraph inside the BorderAnimate component.
Variant
The BorderAnimate component supports five animation variants, each creating a unique visual effect. Use the variant prop to switch between them.
This is a title
This is a paragraph inside the BorderAnimate component.
Beam
The beam variant (default) creates an animated glow that moves around the border. It supports three rendering modes via the beamMode prop:
dot(default) — a radial-gradient dot that travels along the border perimeter via CSSoffset-path. Uniform size at every position and constant speed along the perimeter.wedge— a rotating conic-gradient wedge. The rotation is smooth and continuous, but the visible width varies on rectangular containers (wider at the corners, narrower along the edges) because the sweep is angular rather than linear.comet— a stroked head with a fading tail, drawn along the real perimeter. It is the only mode with a trail, and unlikewedgeits speed is constant on any shape.
dot
size="md"
wedge
spread=36 (default)
wedge
spread=140
comet
tail=25 (default)
Key props for the beam variant:
beamMode- Rendering mode:'dot'(default),'wedge'or'comet'size- Pixel size of the traveling dot (dotmode)spread- Visible width of the wedge in degrees (wedgemode, default 36)tail- Length of the comet tail as a percentage of the perimeter (cometmode, default 25)blur- Softens the effect. It matters most on the comet: SVG cannot fade a stroke along its own path, so the tail is built from stacked strokes, and a small blur — the default — melts their joints togetherduration- Controls how fast the beam travelscolorFrom/colorTo- Colors of the beamcolorStops- Full control over the gradient (overrides colorFrom/colorTo)
tail=15
A quick spark
tail=25
The default
tail=50
Half the perimeter
Glow
The glow variant produces a pulsating glow effect that fades in and out. The entire border area illuminates with a soft, diffused light that pulses rhythmically. This is perfect for attention-grabbing elements or notification indicators.
Key props for glow variant:
duration- Controls the pulse speedblur- Adjusts the softness of the glowborderOpacity- Controls the maximum opacity of the glow
Pulse
The pulse variant creates a subtle scaling animation combined with opacity changes. The border gently expands and fades, creating a breathing effect. This variant is excellent for subtle emphasis without being too distracting.
Key props for pulse variant:
duration- Controls the pulse rhythmblur- Softens the border effect
Draw
The draw variant turns the border into a value. progress says how much of the perimeter is drawn, from 0 to 100, and the stroke follows the real border — corners included — so 50% is exactly half of the way around whatever the aspect ratio of the element is.
Because the drawn length is a transition, changing progress animates smoothly on its own. Set withTrack to render the rest of the perimeter underneath, the way a progress bar shows its remaining part.
Key props for the draw variant:
progress- How much of the border is drawn (0-100, default 100)withTrack/trackColor- Render and color the untouched part of the perimeterduration- Duration of the transition when progress changes (default 1s for this variant)
Uploading assets
The border is the progress bar: 65% complete
Dash
The dash variant paints a dashed border and marches it around the perimeter. Lengths are percentages of the perimeter, not pixels, so the pattern stays even on any size or aspect ratio.
Key props for the dash variant:
dashSize/dashGap- Length of each dash and of each gap, as percentages of the perimeter (default 4 and 4). Both are nudged by up to half a period so that the pattern divides the perimeter exactly: otherwise the last dash would be cut in half right where the perimeter closes, leaving a visible snag at the first cornercount- Number of segments spread evenly along the perimeter; it overrides the absolute lengths and keeps only their ratiodashCap-'butt'(default) or'round'. A tinydashSizewith a round cap gives you dotswithTrack/trackColor- Render the full perimeter underneath the dashes
Marching ants
dashSize 4 · dashGap 4
Dots
dashCap="round"
Four segments
count=4
Triggers
By default the animation runs forever. The trigger prop lets an interaction start it instead, which is usually what you want on something a person can actually touch:
always(default) - animates continuouslyhover- fades in and animates while the pointer is over the wrapperfocus-within- the same, but driven by focus, so it works with real form controlsinView- animates only while the component is inside the viewportnever- renders the resting state and never animates
The transition lasts duration, and for variant="draw" the border literally draws itself as the trigger becomes active.
trigger="hover"
Point at me
trigger="inView"
Idle when scrolled away
Color Stops
The colorStops prop gives you full control over the beam gradient. Each stop has a color (any Mantine color) and a position (0-100%). When provided, it overrides colorFrom/colorTo.
For dot mode, colorStops creates a radial-gradient with concentric color rings inside the traveling dot. For wedge mode, it creates a custom conic-gradient — use transparent stops for a wedge, or fill the entire circle for a rotating gradient border. For the draw and dash variants the stops become a real SVG gradient along the stroke. The comet mode ignores colorStops: it has no gradient to paint into, because SVG cannot fade a stroke along its own path, so its tail is a stack of strokes each mixed between colorFrom and colorTo.
Wedge beam
Wedge with colorStops
Rainbow
Wedge full gradient
Dot beam
Dot with colorStops
Animation Control
Direction and Phase
reverse flips the direction of travel. phase shifts the animation in time: a value of 2 makes the border start as if it had already been running for two seconds, which is how you keep several borders from moving in lockstep. It is a phase offset, not a delay — nothing ever waits.
phase=0
phase=1.33
phase=2.66
reverse
Pause on Hover
Set pauseOnHover to pause the animation when the user hovers over the component. This is useful for interactive elements where the animation might be distracting during interaction.
It is ignored when trigger="hover", since the two would fight over the same gesture: one wants to start the animation on hover, the other wants to stop it.
Hover me!
Beam pauses on hover
Hover me!
Glow pauses on hover
Timing Function
The timingFunction prop controls the CSS animation timing function. By default, beam uses linear (constant speed), while glow and pulse use ease-in-out (smooth acceleration). You can override this with any valid CSS timing function.
linear
Constant speed
ease-in-out
Smooth acceleration
steps(8)
Stepped / retro
Geometry
Three props decide where the ring is drawn and how thick it is.
borderWidth is the thickness of the band the effect is painted into — a Mantine size token (xs is 1px, xl is 8px) or any number. Widening it makes every variant more substantial, not just longer: the beam becomes a broad sweep, the dashes become blocks, the drawn border becomes a stroke you cannot miss.
radius should match the radius of the content you are wrapping, and then the ring stays glued to it. radius="100%" gives a circle on a square element, an ellipse on anything else.
offset pushes the ring outwards, leaving a gap between the content and the animated border. The radius grows by the same amount, so the ring stays concentric with the element instead of looking pinched at the corners.
offset=0
offset=8
offset="lg"
Mask and Background Effects
The withMask and zIndex props allow you to create advanced visual effects, including background glows and layered animations.
withMask
By default, withMask is true, which clips the animated effect to the border area only. Set withMask={false} to let the effect extend beyond the border, creating a softer, more diffused look.
The glow variant is the exception: it defaults to withMask={false}, because its whole point is a halo that spreads outwards. Pass withMask explicitly to clip it into a blurred ring instead.
Dot + mask
Clipped to border
Dot no mask
Glow extends outward
Wedge + mask
Wedge clipped
Wedge no mask
Wedge full gradient
zIndex
The zIndex prop controls the stacking order of the border effect. By default, the border appears in front of the content (zIndex={1}). Set zIndex={-1} combined with withMask={false} to create beautiful background glow effects that appear behind your content.
zIndex=1
Border in front
zIndex=-1
Background glow
Layered
Front + background
Use Cases
BorderAnimate can be used with virtually any Mantine component. Here are some common use cases to inspire your implementations.
Buttons
Add animated borders to buttons to make them stand out. A call to action can animate all the time, but for anything less shouty trigger="hover" is usually the better manner: the button is quiet until the pointer arrives, and then the border draws itself.
Always on
radius=256
trigger="hover"
variant="glow"
Input Fields
trigger="focus-within" is the answer here: the wrapper follows the focus of the control inside it, so the border lights up exactly when the field is active — no state to wire up, and it keeps working with the keyboard. Combine it with variant="draw" and the border writes itself around the field on focus. A field that needs attention before it is touched is the one case where an always-running animation is right.
Alerts and Notifications
Make alerts more noticeable with animated borders. Use different variants and colors to convey urgency levels.
Cards
Create premium-looking cards with animated borders. Great for featured content, pricing cards, or special offers.

Premium Package
Get access to all premium features with our special animated border effect that highlights this exclusive offer.
Chips and Badges
Even small elements like chips can benefit from animated borders to indicate selection or special status.
Accordion
Wrap accordion components with animated borders to create visually engaging expandable sections. The border effect adds a modern touch to FAQ sections or collapsible content areas.
Multiple Borders
Nest multiple BorderAnimate components to create complex, layered effects. Combine different variants, speeds, directions and colors — reverse and phase are what keep the layers from moving in lockstep. This technique is perfect for hero sections or premium UI elements that need extra visual impact.
Multiple Animated Borders
Circular Elements
BorderAnimate works perfectly with circular shapes. Set radius="100%" to create animated borders around avatars, profile pictures, or any circular UI element, and the effect follows the circle instead of cutting corners. It also gives you a ring progress for free: variant="draw" on a square element with radius="100%" measures the circumference exactly.
Circle
Simple circle
Avatar
Pulse
Pulse variant
70%
draw + radius="100%"
Accessibility
BorderAnimate honors the prefers-reduced-motion media query through the Mantine theme. When a user has enabled "Reduce motion" in their operating system settings, every animation and transition is disabled — including the ones on pseudo-elements, which the rule shipped by Mantine core cannot reach on its own.
Because the guard is scoped to theme.respectReducedMotion, an application that deliberately turns that setting off keeps its animations, exactly like every other Mantine component.
The animated ring is decorative and carries aria-hidden, so it is never announced by assistive technology.