Ant Design Svelte

FloatButton

Floating actions, drop-down groups and return to the beginning with progress.

When to use

FloatButton makes a common action available while scrolling: help, feedback or return to the beginning. FloatButtonGroup groups related actions; FloatButtonBackTop watches the scrolling of the selected area.

Components are imported separately. In the examples, the buttons are located inside local areas so that the demos do not overlap the site menu. In an application, the standard fixed position refers to the viewport.

FloatButton CSS Prefixes show global ConfigProvider.prefixCls and local prefixCls without resetting state. A child button without prefixCls inherits Group; an empty line selects ConfigProvider. BackTop and Progress retain independent settings. The buttons are limited to the example area.

Action and group

FloatButton creates a native button or link with an href. type selects default/primary, shape selects circle/square, icon and content specify the icon and caption. For an icon-only button, give it an accessible name.

Problem Setting Example
Show single action FloatButton, onclick Floating action
Add a signature or link content, href Content and link
Merge Actions FloatButtonGroup.items Action group
Expand menu trigger, open, onOpenChange Controlled disclosure
Follow the Scroll FloatButtonBackTop.target Return to the beginning of the container

items of the group contains unique key and children snippets. The overall shape is inherited by child buttons; the content, type, and handler are specified by the actions themselves. Without trigger, the group shows the usual set of buttons. trigger=click/hover enables a dropdown menu.

With managed open, take the new value from onOpenChange. placement sets the opening direction, closeIcon — the closing icon. Selecting a child action does not automatically close the menu: if the script needs it, update the open in the handler. Menu compares clicking and hovering.

Return to the beginning and position

BackTop follows window by default and appears after visibilityHeight=400. Local target returns Window, Document, HTMLElement or null. null means the container is not yet ready and is not replaced by window. If visibilityHeight=0, the button is visible immediately after the area is ready.

duration specifies the return duration, default is 450 ms. With reduced motion, animation is not used. showProgress adds a scrolling progress ring; ring example shows it regardless of other actions.

target defines the watchable area, and CSS defines the position of the button. To limit it to a card, the examples create a relative container and place an absolutely button. In the application, match the inset and z-index with the header and other floating layers. Changing target does not make the fixed position snap to its bounds.

Tips and design

Tooltip accepts the contents or Tooltip settings without children. Badge adds a counter or dot; Badge status mode does not apply to this setting. Counter and point are shown side by side.

classNames/styles are available for button and group; styles contains CSS strings, and callbacks receive props. Slots groups include list, elements, and trigger. Semantic example shows local decoration and ConfigProvider.floatButtonGroup.

ConfigProvider.floatButton has backTopIcon running. The rest of its design fields are accepted by the types, but the installed FloatButton does not yet read them; use local props. FloatButton named component design tokens have not yet been published, theme.components.FloatButton is not connected. General colors and sizes are inherited from the theme.

Buttons retain the native keyboard and disabled state. BackTop has no bind:nativeElement until the button is visible. Determine the availability of an action by its state and handler, and not just by the visibility of the tooltip.

Examples

Action at the bottom edge

0

Floating action

FloatButton remains at the edge of the area. Positioning is limited to the example card; on the working page default fixed refers to viewport.

Types and unavailable action

default and primary define the design; disabled disables the native button.

Button shape

circle and square; the group shapes its children through context.

@

Contents and link

content accepts text or snippet. href creates a real link.

Action prompt

tooltip accepts a string or public Tooltip props. The tooltip complements the available button name.

Select action

Action group

items contains separate snippets. group shape takes precedence over children's shape; The type of actions is specified for each separately.

Select action

Click and hover menu

trigger selects click or hover. Selecting a child action does not automatically close the group.

Closed

Select action

Controlled opening

open and onOpenChange are related to the application state. External buttons control the same menu.

Select action

Opening direction

placement specifies the position of the list relative to the trigger. The trigger position leaves room for the list in the selected direction.

Start of list

Return to the beginning of the container

target selects the scroll container, visibilityHeight is the appearance threshold, duration is the return duration. ConfigProvider.floatButton changes backTopIcon.

List contents

Scroll ring

showProgress shows the scroll percentage of the selected target. Returning to the beginning simultaneously resets progress.

Counter and Badge point

badge accepts compatible Badge options. status/text/title/children excluded; the available name is given to the button itself.

Semantic slots and group configuration

Local styles style the root/icon/content buttons. ConfigProvider.floatButtonGroup specifies styles for elements and their icons.

Actions in a group and return to the beginning of a separate scroll area.

Start of list

End of list

0

Actions and project scrolling

Saved review example: action group and BackTop with progress.

Scroll this area
Actions: 0
General: suite; local: project-float-btn

A child button without prefixCls inherits Group; an empty line selects ConfigProvider. BackTop and Progress retain independent settings. The buttons are limited to the example area.

FloatButton CSS prefixes

Common namespace ConfigProvider and local prefixCls; the state of the component is preserved when the name is changed.

API

Themes of the ant.design live page are mapped to the public API of the installed package. Full definitions of Props are in @woodger/antd.

Topics of official examples
ThemeExample or limitation
BasicPositioned action.
Typedefault/primary/disabled.
Shapecircle/square.
ContentText, icon and link.
FloatButton with tooltipTooltip props.
FloatButton GroupIndividual snippets and overall shape.
Menu modeclick/hover.
Controlled modeopen and onOpenChange.
placementFour directions of the list.
draggableGroup drag and drop API is missing from React 6.7. Native HTML draggable does not implement this scenario.
BackTopOwn scroll target and duration.
Progress ringScroll share.
badgeNumber and point.
Custom semantic dom stylingLocal slots and group configuration.
Basic parameters of FloatButton
PropertyDescriptionTypeDefault
prefixClsBasic button prefix. undefined inherits Group if there is one; an empty line selects ConfigProvider. Group gets the base prefix without -group.stringConfigProvider.prefixCls + "-float-btn"
typeButton design; in the group refers to trigger, children set their own type.default | primarydefault
shapeShape; The shape of a group takes precedence among its children.circle | squarecircle
iconString or snippet of the icon.ButtonContentDocument icon
contentText or snippet of the button content.ButtonContent—
tooltipHint with text or parameter object.FloatButtonContent | TooltipProps—
badgeBadge without status/text/title/children.FloatButtonBadge—
hrefNative link instead of button.string—
disabledUnavailable action; can be inherited from Form/ConfigProvider.booleanfalse
onclickNative Svelte callback; onClick is saved as a compatible alias.MouseEventHandler—
classNamesLocal classes root/icon/content.ButtonSlots | function—
stylesCSS strings for these slots.ButtonSlots | function—
nativeElementNative action ref.HTMLButtonElement | HTMLAnchorElement—

FloatButtonGroup

items — key/children snippets array; children is also supported. trigger: click/hover, open: boolean, onOpenChange: callback. placement: top/bottom/left/right, closeIcon: content of the closing icon. Selecting a child action does not automatically close the menu.

FloatButtonBackTop

target returns Window, Document, HTMLElement, or null. default visibilityHeight is 400px, duration is 450ms, showProgress is false. onclick is called along with the start of the return. bind:nativeElement is missing while the button is not visible.

Semantic DOM

FloatButton creates a native button or a with root/icon/content slots. FloatButtonGroup creates a div role="group", list and trigger; available root/list/item/itemIcon/itemContent/trigger/triggerIcon/triggerContent. styles accepts CSS strings, objects and functions are supported.

In the examples, positioning is limited to local areas so that actions do not overlap the site menu. In an application, default fixed refers to the viewport; consider the header and z-index.

ConfigProvider.floatButtonGroup applies group styles. ConfigProvider.floatButton has backTopIcon; class/style/classNames/styles are present in the types, but the installed FloatButton does not read them yet. For a single button, use local props.

Registration tokens

The public ComponentTokenMap.FloatButton does not yet describe named component tokens, and the theme.components.FloatButton mechanism is not connected. Own design is shown through styles and group configuration. General colors and sizes are inherited from the theme.

Common tokens of the current topic
TokenCurrent value
colorBorderSecondary#f0f0f0
colorPrimary#2f54eb
colorTextrgba(0,0,0,0.88)
borderRadius6
borderRadiusLG8
boxShadowSecondary 0 6px 16px 0 rgba(0,0,0,0.08), 0 3px 6px -4px rgba(0,0,0,0.12), 0 9px 28px 8px rgba(0,0,0,0.05)
controlHeight32
controlHeightLG40
fontFamily-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji'
fontSize14
fontSizeIcon12
fontSizeSM12
lineHeight1.5714285714285714
lineWidthBold2
marginLG24
marginXXL48
motionDurationMid0.2s
motionDurationSlow0.3s
padding16
paddingXXS4
zIndexPopupBase1000

FAQ

How to set multiple actions in a group?

Pass items with unique key and children snippets. The general form is inherited, the content and type are set by the child FloatButton.

Why doesn't the guided menu open?

We need trigger=click/hover and taking next from onOpenChange to the open state.

Why didn't BackTop appear?

Check the readiness of target, scrollTop and visibilityHeight. Returning null means waiting for the container.

How to limit buttons to an area?

Set a local containing block and appropriate CSS positioning, as in the examples. By default, buttons are anchored relative to the viewport.