Ant Design Svelte

BorderBeam

Decorative ray along the border: container, hover, multiple rays, gradients, speed, size and thickness.

When to use

BorderBeam adds a moving decorative beam along the border of a card or other container. It helps highlight an area without creating business status. Keep the usual focus ring, error border, and text explanation regardless of decoration.

Real DOM container and target

In Svelte the target is passed explicitly: bind:this of a regular element or bind:nativeElement of a component, for example Card. The DOM-ref is not automatically extracted from children. children is output without any additional wrapper.

Problem Opportunity Example
Highlight card Card.nativeElement, target Beam around the card
Show effect when interacting CSS hover/focus Pointing and Focus
Distribute multiple rays count Multiple layers
Transfer decoration between nodes change target Your own container
Choose a color transition color Gradients
Fit effect into crop outset={0} Thickness and borders

Decoration is created only for HTMLElement. SVGElement is allowed by the type, but ignored by runtime. The container must specify a positioning context, usually position:relative. The effect requires support for CSS mask-composite and offset-path. Before mount or without a suitable target, the usual content remains.

Color, number and size of beam

count evenly distributes the rays and their phases. The final value from 1 is rounded down, the rest are replaced by 1. duration sets the revolution in seconds, default - 6; CSS animation does not require a background JS application timer.

color accepts one CSS color or an array of stops with percent from 0 to 100 in the desired order. The stops are scaled to the colored 70% gradient, leaving a transparent tail. This is not a percentage of the path length.

size specifies the side of the moving square layer. A square that is too large may highlight the opposite side. Choose a size noticeably smaller than twice the short side of the container and take into account the radius, lineWidth and outset.

lineWidth and outset accept a number in px or a CSS length. The radius is inherited via CSS and updated with the container. Automatic outset - a snapshot of four border-width values when binding a target; for dynamic thickness, set it explicitly. outset:0 is needed for a container with overflow:hidden.

Life cycle, theme and limitations of

When changing target, old layers are deleted, new ones are added to the new HTMLElement. Disabling the effect and unmount removes the decoration while preserving the original DOM. SSR displays content without decorative layers.

Prefers-reduced-motion hides the beam and disables animation. The effect is aria-hidden, does not intercept the pointer and does not participate in Tab order. Therefore, the semantics and availability of the action are determined by the container itself and its contents.

ConfigProvider.borderBeam sets the general class/style. Then the local style is applied, followed by the explicit props variables. Without color, primary/primaryHover themes are used. There are no named semantic slots or BorderBeam component design tokens.

items and BorderBeamItem from Ant Design 6.7 have not yet been carried over. The current API uses count with generic color/lineWidth/outset/size. Do not transfer new per-beam settings to an example without public package support.

A non-empty local prefixCls specifies the full CSS class of each layer. The empty string and undefined inherit ConfigProvider.prefixCls with the -border-beam suffix, defaulting to ant-border-beam. Example of prefixes uses one local project-beam in two independent areas. Changing prefix preserves layers, target, editor DOM, focus and selection; the animation name antBorderBeamMove remains the same.

Geometry service variables use a common provider prefix without dots: for example, --suite-border-beam-*. Local prefixCls and theme.cssVar.prefix have no effect on this namespace. These are internal parameters: set duration/size/lineWidth/outset via props. For hover and other custom CSS, use a class rather than binding to the standard ant-border-beam.

Examples

Svelte Documentation

The ray follows the radius of the true root of the Card.

Presses: 0

Beam around Card

bind:nativeElement of the Card root, without additional wrapper.

Hover or focus on a button.

Display with hover and focus

Hiding via CSS; the keyboard also reveals the scenery.

Uniform distribution along the contour.

Multiple beams

count distributes the rays and their negative phases evenly.

First container
Second container

Own container

Explicit target, switching between nodes and removing effect.

Forest: color stops 0–100%.
#237804: 0%; #a0d911: 50%; #faad14: 100%

Gradients

Six palettes with 0-100% stops and a transparent tail.

Full turn for 6 seconds.

Turnover time

3, 6 or 12 seconds without timers in the app.

Gradient layer size: 100 px.

Segment size

56, 100 or 160px; the size of the square layer, not the length of the path.

Outset=0 keeps the effect inside the clipped container.

Thickness and outset

Numerical thickness and outset=0 for overflow: hidden.

The color is taken from the theme; local style overrides provider transparency.

Theme and ConfigProvider

Color/thickness from tokens, nested RTL, class/style and local priority.

Single beam independent area.

General: suite; class: project-beam

The same local class does not mix the parameters of the two areas. The namespace of the utility geometry follows a common prefix, separate from theme.cssVar.prefix.

Local and general prefix

Same class in different areas, independent ray parameters and saving the editor.

Light along the border

Several rays move along the contour of the card. Choose their number or turn off the effect.

Initial interactive example

Saved demo with effect enabled and number of rays selected.

API

Themes and behavior verified against BorderBeam on ant.design 6.7.0. The current build retains the 6.6.8 generation API and replaces React child ref with an explicit target. The new items from 6.7 are not yet supported.

Example themes
ThemeExample or limitation
BasicCard with an explicit DOM target.
Show on hoverCSS hover/focus-within; also available from the keyboard.
Multiple beamscount supported. New items from 6.7 and BorderBeamItem are not yet available.
Custom containerNative HTMLElement and target rebinding.
GradientsSix palettes, percent 0–100 and a transparent tail.
DurationDuration of a full revolution in seconds.
SizeThe size of the moving square gradient layer.
Line widthlineWidth and explicit outset in the clipped container.
CSS prefixesLocal classes and common namespace of geometry of independent areas.

BorderBeam

PropertyDescriptionTypeDefault
prefixClsFull local CSS layer class. The empty string and undefined inherit the same prefix. The namespace of service variables depends on ConfigProvider.prefixCls, separate from the local class and theme.cssVar.prefix.stringConfigProvider + -border-beam
targetIn fact, decoration is created only for HTMLElement. SVGElement is accepted by the type but ignored. Without target, only children remain.HTMLElement | SVGElement | null—
childrenContents without new wrapper. boolean/null are not output.Snippet | string | number | boolean | null—
colorA color or array of color stops in original order.string | BorderBeamGradientprimary / primaryHover
countFinal number ≥1 is rounded down; other values are replaced by 1.number1
durationDuration of rotation in seconds.number6
lineWidthLine thickness. Number - px, line - CSS length.number | stringtheme.lineWidth
outsetExternal offset. 0 keeps the layer inside. Border widths are measured when the target is changed, not every time the CSS is changed.number | stringshot border-width target
sizeThe size of the square gradient layer.number | string100px
classA local class is added to the provider class on each layer.stringConfigProvider.borderBeam.class
styleLocal CSS comes after provider; explicit props set variables after style.stringConfigProvider.borderBeam.style

BorderBeamGradient: color stop

PropertyDescriptionTypeDefault
colorCSS color color stop.stringis required
percentPosition 0–100 displayed in color 70% layer; the remaining part fades to transparent.numberis required

ConfigProvider.borderBeam

PropertyDescriptionTypeDefault
classGeneral class of all decorative layers.string—
styleGeneral CSS layers; local style takes precedence. The nested borderBeam config is replaced entirely.string—

Decorative layers are added after mount inside the HTMLElement and removed when the target is changed or unmounted. children is simply output without any additional wrapper; target is not automatically determined by it.

Semantic DOM

The official page does not publish Semantic DOM slots BorderBeam. The actual @woodger/antd layers are described below: class/style refers to the decoration, not the host. Layers are excluded from the accessibility tree and do not intercept the pointer.

The selectors below are for the standard prefix. For native CSS, pass persistent class, as in the hover example: it persists when changed prefixCls.

Actual markings
ElementPurpose
targetAn existing container with position: relative and radius. Its markings belong to the owner.
.ant-border-beamDecorative div inside target, aria-hidden=true and pointer-events=none. One layer per beam.
.ant-border-beam::beforeMoving square gradient, CSS offset-path and mask. Hidden during reduced motion.

Registration tokens

BorderBeam does not have its own component tokens. The default color and line thickness are inherited from the three common tokens below. Props color/lineWidth override them for a specific ray.

Common tokens of the current topic
TokenMeaning
colorPrimary#2f54eb
colorPrimaryHover#597ef7
lineWidth1

FAQ

Why didn't the beam appear?

We need a real HTMLElement in the target, a positioned container and CSS support. Use bind:this or bind:nativeElement.

What happens with reduced motion?

The beam is hidden, but the normal border and content remain.

What does percent mean at the color stop?

A position from 0 to 100, scaled to the visible part of the gradient with a transparent tail.

Why does large size highlight the opposite edge?

This is the size of the square layer. Compare it to the short side of the container, not the length of the path.

Is the radius and thickness updated?

Radius is inherited through CSS. Automatic outset is measured when changing target; for dynamic thickness, pass outset explicitly.

What remains after changing target or unmount?

Decorative layers are removed from the old node. The original content is retained.

Are there items for individual rays?

Not yet. count and general settings supported; per-beam API 6.7 remains a gap.

How to redefine the appearance?

Provider style, then local style, then explicit props variables. class is added to the general provider class.