logoNamu Design

⌘ K
  • Design
  • Development
  • Components
  • Blog
  • Resources
1.0.0
  • Components Overview
  • General
    • Button
    • FloatButtonNew
    • Icon
    • Typography
  • Layout
    • Divider
    • Grid
    • Layout
    • Space
  • Navigation
    • Anchor
    • Breadcrumb
    • Dropdown
    • Menu
    • Pagination
    • Steps
  • Data Entry
    • AutoComplete
    • Cascader
    • Checkbox
    • ColorPickerNew
    • DatePicker
    • Form
    • Input
    • InputNumber
    • Mentions
    • Radio
    • Rate
    • Select
    • Slider
    • Switch
    • TimePicker
    • Transfer
    • TreeSelect
    • Upload
  • Data Display
    • Avatar
    • Badge
    • Calendar
    • Card
    • Carousel
    • Collapse
    • Descriptions
    • Empty
    • Image
    • List
    • Popover
    • QRCodeNew
    • Segmented
    • Statistic
    • Table
    • Tabs
    • Tag
    • Timeline
    • Tooltip
    • TourNew
    • Tree
  • Feedback
    • Alert
    • Drawer
    • Message
    • Modal
    • Notification
    • Popconfirm
    • Progress
    • Result
    • Skeleton
    • Spin
    • Watermark
  • Other
    • Affix
    • AppNew
    • ConfigProvider
When To Use
Examples
Basic
Horizontal Anchor
Static Anchor
Customize the onClick event
Customize the anchor highlight
Set Anchor scroll offset
Listening for anchor link change
Replace href in history
API
Anchor Props
AnchorItem
Link Props
Design Token

Anchor

  • SpaceBreadcrumb

    Resources

    Namu Design Charts
    Namu Design Pro
    Namu Design Pro Components
    Namu Design Mobile
    Namu Design Mini
    Namu Design Landing-Landing Templates
    Scaffolds-Scaffold Market
    Umi-React Application Framework
    dumi-Component doc generator
    qiankun-Micro-Frontends Framework
    ahooks-React Hooks Library
    Ant Motion-Motion Solution
    China Mirror 🇨🇳

    Community

    Awesome Namu Design
    Medium
    Twitter
    yuqueNamu Design in YuQue
    Namu Design in Zhihu
    Experience Cloud Blog
    seeconfSEE Conf-Experience Tech Conference

    Help

    GitHub
    Change Log
    FAQ
    Bug Report
    Issues
    Discussions
    StackOverflow
    SegmentFault

    Ant XTechMore Products

    yuqueYuQue-Document Collaboration Platform
    AntVAntV-Data Visualization
    EggEgg-Enterprise Node.js Framework
    kitchenKitchen-Sketch Toolkit
    xtechAnt Financial Experience Tech
    Theme Editor
    Made with ❤ by
    Ant Group and Namu Design Community

    Hyperlinks to scroll on one page.

    When To Use

    For displaying anchor hyperlinks on page and jumping between them.

    Notes for developers

    After version 4.24.0, we rewrite Anchor use FC, Some methods of obtaining ref and calling internal instance methods will invalid.

    Examples

    Basic

    The simplest usage.

    expand codeexpand code
    Horizontal Anchor

    Horizontally aligned anchors

    expand codeexpand code
    Static Anchor

    Do not change state when page is scrolling.

    expand codeexpand code
    Customize the onClick event

    Clicking on an anchor does not record history.

    expand codeexpand code
    Customize the anchor highlight

    Customize the anchor highlight.

    expand codeexpand code
    Set Anchor scroll offset

    Anchor target scroll to screen center.

    expand codeexpand code
    Listening for anchor link change

    Listening for anchor link change.

    expand codeexpand code
    Replace href in history

    Replace path in browser history, so back button returns to previous page instead of previous anchor item.

    expand codeexpand code

    API

    Common props ref:Common props

    Anchor Props

    PropertyDescriptionTypeDefaultVersion
    affixFixed mode of Anchorbooleantrue
    boundsBounding distance of anchor areanumber5
    getContainerScrolling container() => HTMLElement() => window
    getCurrentAnchorCustomize the anchor highlight(activeLink: string) => string-
    offsetTopPixels to offset from top when calculating position of scrollnumber0
    showInkInFixedWhether show ink-square when affix={false}booleanfalse
    targetOffsetAnchor scroll offset, default as offsetTop, examplenumber-
    onChangeListening for anchor link change(currentActiveLink: string) => void
    onClickSet the handler to handle click event(e: MouseEvent, link: object) => void-
    itemsData configuration option content, support nesting through children{ key, href, title, target, children }[] see-5.1.0
    directionSet Anchor directionvertical | horizontalvertical5.2.0
    replaceReplace items' href in browser history instead of pushing itbooleanfalse5.7.0

    AnchorItem

    PropertyDescriptionTypeDefaultVersion
    keyThe unique identifier of the Anchor Linkstring | number-
    hrefThe target of hyperlinkstring
    targetSpecifies where to display the linked URLstring
    titleThe content of hyperlinkReactNode
    childrenNested Anchor Link, Attention: This attribute does not support horizontal orientationAnchorItem[]-
    replaceReplace item href in browser history instead of pushing itbooleanfalse5.7.0

    Link Props

    We recommend using the items form instead.

    PropertyDescriptionTypeDefaultVersion
    hrefThe target of hyperlinkstring
    targetSpecifies where to display the linked URLstring
    titleThe content of hyperlinkReactNode

    Design Token

    Component Token

    Global Token

    Basic demo
    Static demo
    API
    Anchor Props
    Link Props
    Basic demo
    Static demo
    API
    Anchor Props
    Link Props
    Basic demo
    Static demo
    API
    Anchor Props
    Link Props
    Basic demo
    Static demo
    API
    Anchor Props
    Link Props