Skip to main content
Neural UIv2.0.0Documentation
View v1 GitHub

ScrollTop

Return the page or a parent scroll panel to its start after a scroll threshold.

Category
Navigation
Import
@neural-ui/core/scroll-top
Selector
neu-scroll-top
import { NeuScrollTopComponent } from '@neural-ui/core/scroll-top';

Usage

Choose target="window" to observe page scrolling, or target="parent" for the immediate parent element. Give that parent a bounded height and overflow:auto. threshold is a vertical scroll distance in pixels; the button appears above it. behavior chooses auto or smooth scrolling. The default chevron is built in and needs no icon provider.

Examples

Try the interaction and open Code for the complete implementation.

Examples

Scroll the panel down to reveal the return button. The window option observes the page instead.

Chapter 1

Read this section, then continue to the next chapter.

Chapter 2

Read this section, then continue to the next chapter.

Chapter 3

Read this section, then continue to the next chapter.

Chapter 4

Read this section, then continue to the next chapter.

Chapter 5

Read this section, then continue to the next chapter.

Chapter 6

Read this section, then continue to the next chapter.

Chapter 7

Read this section, then continue to the next chapter.

Chapter 8

Read this section, then continue to the next chapter.

Chapter 9

Read this section, then continue to the next chapter.

Chapter 10

Read this section, then continue to the next chapter.

Chapter 11

Read this section, then continue to the next chapter.

Chapter 12

Read this section, then continue to the next chapter.

Try and configure

Change the options, try the result and see the template update. Code contains the full executable example.

Try and configure

Scroll the panel down to reveal the return button. The window option observes the page instead.

Chapter 1

Read this section, then continue to the next chapter.

Chapter 2

Read this section, then continue to the next chapter.

Chapter 3

Read this section, then continue to the next chapter.

Chapter 4

Read this section, then continue to the next chapter.

Chapter 5

Read this section, then continue to the next chapter.

Chapter 6

Read this section, then continue to the next chapter.

Chapter 7

Read this section, then continue to the next chapter.

Chapter 8

Read this section, then continue to the next chapter.

Chapter 9

Read this section, then continue to the next chapter.

Chapter 10

Read this section, then continue to the next chapter.

Chapter 11

Read this section, then continue to the next chapter.

Chapter 12

Read this section, then continue to the next chapter.

Template generated from your current options. Open Code for the complete example.

template.html
<neu-scroll-area
  maxHeight="16rem"
  [mask]="false"
  ariaLabel="Scrollable reading panel"
>
  <!-- Add your scrollable content here. -->
  <neu-scroll-top
    target="parent"
    behavior="smooth"
    [threshold]="100"
  [buttonAriaLabel]="'Back to top'"
/>
</neu-scroll-area>

Data and content

ScrollTop observes browser scroll state and scrolls its target when activated. It has no Outputs. icon resolves an optional application-provided icon key; neuScrollTopIcon replaces the visual icon with projected content while preserving the native button label.

Accessibility and keyboard

Translate buttonAriaLabel to describe the destination. Tab reaches the visible button; Enter or Space activates it. Decorative Template icons should be aria-hidden. The component checks browser availability and does not access a missing window during server rendering.

Key
Action
Tab Focus the button when visible and enabled.
Enter Scroll to the destination named by the button.
Space Scroll to the destination named by the button.

API

Inputs and Outputs match the installed package. Named types link to definitions. Every available Template has a Demo and Code example.

Inputs

Configure the component with [property]="value". Your application supplies these values; the component does not replace the state you pass in.

Name
Type
Default
Template binding
Description
behaviorNeuScrollTopBehavior'smooth'[behavior]Use immediate auto or animated smooth scrolling.
buttonAriaLabelstring'Scroll to top'[buttonAriaLabel]Label for return-to-top button. Translate it for your application.
iconstring'chevron-up'[icon]Optional provided icon key; default chevron-up is built in.
targetNeuScrollTopTarget'window'[target]Observe the window or the immediate parent scroller.
thresholdnumber400[threshold]Vertical scroll distance in pixels above which the button appears.

Templates

ng-content projects content into the component. TemplateRef inputs receive a template; ng-template directives identify templates with a typed context. A directive shared by an entrypoint is not necessarily a slot of this component.

Name
Mechanism
Contract
NeuScrollTopIconDirectiveView example Public template directive (entrypoint)ng-template[neuScrollTopIcon]

Each example demonstrates a different template. Switch between Demo and Code to inspect its implementation, imports and state.

Custom return icon

NeuScrollTopIconDirective

Custom return icon

Scroll the panel down to reveal the return button. The window option observes the page instead.

Chapter 1

Read this section, then continue to the next chapter.

Chapter 2

Read this section, then continue to the next chapter.

Chapter 3

Read this section, then continue to the next chapter.

Chapter 4

Read this section, then continue to the next chapter.

Chapter 5

Read this section, then continue to the next chapter.

Chapter 6

Read this section, then continue to the next chapter.

Chapter 7

Read this section, then continue to the next chapter.

Chapter 8

Read this section, then continue to the next chapter.

Chapter 9

Read this section, then continue to the next chapter.

Chapter 10

Read this section, then continue to the next chapter.

Chapter 11

Read this section, then continue to the next chapter.

Chapter 12

Read this section, then continue to the next chapter.

Public Types

Open a type to inspect its definition and interface fields.

Styles and tokens

Customize supported public tokens and check both themes. Example illustrations and application state are not Core inputs.

Specific tokens

This component uses shared theme tokens rather than dedicated component hooks.

Shared tokens used

Override these on a local wrapper to affect this example. An override on :root affects other components that use the same token.

Token
Purpose here
Other impact
Default / fallback
--neu-primary Brand color for active controls and emphasis Shared by other Core consumers; scope the override. #007aff
--neu-primary-fg Foreground drawn over the primary background Shared by other Core consumers; scope the override. #ffffff
--neu-primary-solid Solid brand action background Shared by other Core consumers; scope the override. #006ee6
--neu-primary-solid-fg Foreground of solid brand actions Shared by other Core consumers; scope the override. #ffffff
--neu-focus-ring-color Inherited theme value used by this component Shared by other Core consumers; scope the override. var(--neu-focus-color)
--neu-radius-full Corner radius Shared by other Core consumers; scope the override. 9999px
--neu-shadow-lg Surface or overlay elevation Shared by other Core consumers; scope the override. 0 10px 30px rgba(15, 23, 42, 0.1), 0 4px 8px rgba(15, 23, 42, 0.04)
--neu-space-4 Spacing between content and controls Shared by other Core consumers; scope the override. 1rem