Anchor

Designer doc
Anchor is a in-page navigation that extracts the main sections of a page content and allow users to quick jump to the section that they are looking for via the overview structure of page content displayed in anchor.

Example

Basic Usage
For Anchor to work properly, we need to first wrap the page in Anchor then provide getTargetProps props from useAnchorTarget with matching anchorId with the AnchorItem on Anchor Title and also provide getContainerProps props from useAnchorContainer hook on the scrollable container
View code
Variants
Anchor have variants: Basic (default), and Multilevel. For Multilevel anchor, can provide different level to AnchorItem, level 1 for main anchor while 2 for sub-anchor.
View code
Orientation
AnchorList also come with orientation Vertical (default) and Horizontal. Horizontal anchor list doesn’t have Multilevel variants.
View code
Customization
offset and scrollOptions can be provided to customize scroll behaviour. You can get some useful props like activeId, setActiveId, anchorsRef, containerRef, anchorItemsRef, anchorListRef from useAnchorContext
View code
References

API

Anchor
Prop nameTypeDefaultDescription
offsetnumber0
scrollOptionsCustomBehaviorOptions<void>
AnchorItem
Prop nameTypeDefaultDescription
anchorIdstring
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
disabledboolean
Equivalent to button's disabled property.
ellipsisTooltipPropsOmit<EllipsisTooltipProps, "children">
keyboardClickKeysstring[]
levelItemLevel1
onBlurFocusEventHandler<HTMLDivElement>
onClickMouseEventHandler<HTMLDivElement>
onKeyDownKeyboardEventHandler<HTMLDivElement>
onKeyUpKeyboardEventHandler<HTMLDivElement>
onMouseDownMouseEventHandler<HTMLDivElement>
onMouseLeaveMouseEventHandler<HTMLDivElement>
onMouseUpMouseEventHandler<HTMLDivElement>
onReleaseEventHandler<SyntheticEvent<HTMLDivElement, Event>>
Callback that's triggered after click i.e. mouseup and keyup of enter or space.
onTouchEndTouchEventHandler<HTMLDivElement>
onTouchStartTouchEventHandler<HTMLDivElement>
selectedboolean
AnchorList
Prop nameTypeDefaultDescription
asany
Tag or component, but a simple tag (i.e. built-in components, e.g. div, span) is recommended.
orientationAnchorListOrientationsvertical
variantAnchorListVariantsbasic
    Example
    Example
    Basic Usage
    Basic Usage
    Variants
    Variants
    Orientation
    Orientation
    Customization
    Customization
    References
    References
    API
    API
    Anchor
    Anchor
    AnchorItem
    AnchorItem
    AnchorList
    AnchorList
Coral is a thoroughly developed design system widely adopted by developers and designers for creating beautiful and user-friendly Sea internal products.

Copyright © 2018-2025 Sea Labs