diff --git a/pages/anchor-navigation/basic.page.tsx b/pages/anchor-navigation/basic.page.tsx
index b5349836ef..8aa5339100 100644
--- a/pages/anchor-navigation/basic.page.tsx
+++ b/pages/anchor-navigation/basic.page.tsx
@@ -4,6 +4,7 @@ import React from 'react';
import AnchorNavigation from '~components/anchor-navigation';
import { TextSample } from './utils';
import SpaceBetween from '~components/space-between';
+import Header from '~components/header';
import ScreenshotArea from '../utils/screenshot-area';
import styles from './styles.scss';
@@ -40,17 +41,20 @@ export default function SimpleAnchorNavigation() {
+
+ On this page
+
diff --git a/pages/anchor-navigation/expandable.page.tsx b/pages/anchor-navigation/expandable.page.tsx
index be57ba715b..117c89c387 100644
--- a/pages/anchor-navigation/expandable.page.tsx
+++ b/pages/anchor-navigation/expandable.page.tsx
@@ -6,6 +6,7 @@ import { TextSample } from './utils';
import SpaceBetween from '~components/space-between';
import ScreenshotArea from '../utils/screenshot-area';
import styles from './styles.scss';
+import { ExpandableSection } from '~components';
const TextContent = () => {
return (
@@ -40,19 +41,20 @@ export default function SimpleToc() {
-
+
+
+
diff --git a/src/anchor-navigation/index.tsx b/src/anchor-navigation/index.tsx
index 00a05c6338..1a3d69a852 100644
--- a/src/anchor-navigation/index.tsx
+++ b/src/anchor-navigation/index.tsx
@@ -7,7 +7,7 @@ import InternalAnchorNavigation from './internal';
export { AnchorNavigationProps };
-export default function AnchorNavigation({ variant = 'default', ...props }: AnchorNavigationProps) {
- return ;
+export default function AnchorNavigation({ ...props }: AnchorNavigationProps) {
+ return ;
}
applyDisplayName(AnchorNavigation, 'Anchor Navigation');
diff --git a/src/anchor-navigation/interfaces.ts b/src/anchor-navigation/interfaces.ts
index 80d26cc4b1..5d251c7659 100644
--- a/src/anchor-navigation/interfaces.ts
+++ b/src/anchor-navigation/interfaces.ts
@@ -5,9 +5,14 @@ import { CancelableEventHandler } from '../internal/events';
export interface AnchorNavigationProps {
/**
- * The title of the table of contents, displayed above the anchor items.
+ * Adds `aria-labelledby` to the component. If you're using this component within a form field,
+ * don't set this property because the form field component automatically sets it.
+ *
+ * Use this property for identifying the header or title that labels the anchor navigation.
+ *
+ * To use it correctly, define an ID for the element you want to use as label and set the property to that ID.
*/
- title?: string;
+ ariaLabelledby?: string;
/**
* List of anchors.
@@ -16,36 +21,22 @@ export interface AnchorNavigationProps {
/**
* Specifies the active anchor.
- * For using the component in a controlled pattern, use together with 'disableTracking'.
+ * For using the component in a controlled manner, use together with 'disableTracking'.
*/
activeAnchor?: AnchorNavigationProps.Anchor;
- /**
- * The variant of the component:
- * 'default' - Use in any context.
- * 'expandable' - Allows users to expand or collapse the component to save vertical space.
- */
- variant?: 'default' | 'expandable';
-
- /**
- * Determines whether the component initially displays in expanded state.
- * The component operates in an uncontrolled manner even if you provide a value for this property.
- * Only applies when the `variant` is set to `expandable`.
- */
- defaultExpanded?: boolean;
-
/**
* Option to disable scroll spy.
*/
disableTracking?: boolean;
/**
- * Triggered when an anchor link is clicked without any modifier keys.
+ * Fired when an anchor link is clicked without any modifier keys.
*/
onFollow?: CancelableEventHandler;
/**
- * Triggered when an active anchor link changes.
+ * Fired when an active anchor link changes.
*/
onActiveAnchorChange?: CancelableEventHandler;
}
@@ -58,9 +49,10 @@ export namespace AnchorNavigationProps {
text: string;
/**
- * The `id` attribute used to specify a unique HTML element.
+ * The `id` attribute of the target HTML element to which this anchor refers.
+ * For example: `"#section1.1"`
*/
- id: string;
+ href: string;
/**
* The level of nesting.
diff --git a/src/anchor-navigation/internal.tsx b/src/anchor-navigation/internal.tsx
index ca08516e3c..d761e3e37b 100644
--- a/src/anchor-navigation/internal.tsx
+++ b/src/anchor-navigation/internal.tsx
@@ -1,14 +1,11 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
-import React from 'react';
+import React, { useMemo } from 'react';
import clsx from 'clsx';
import styles from './styles.css.js';
-import InternalBox from '../box/internal.js';
-import InternalSpaceBetween from '../space-between/internal.js';
import { AnchorNavigationProps } from './interfaces.js';
import { checkSafeUrl } from '../internal/utils/check-safe-url.js';
import useScrollSpy from './scroll-spy.js';
-import InternalExpandableSection from '../expandable-section/internal.js';
const navigateToItem = (event: React.MouseEvent, id: string) => {
event.preventDefault();
const href = event.currentTarget.getAttribute('href');
@@ -17,19 +14,20 @@ const navigateToItem = (event: React.MouseEvent, id: string)
el?.scrollIntoView();
}
};
-const Anchor = ({ id, text, level, isActive }: AnchorNavigationProps.Anchor & { isActive: boolean }) => {
- checkSafeUrl('SideNavigation', id);
+const Anchor = ({ href, text, level, isActive }: AnchorNavigationProps.Anchor & { isActive: boolean }) => {
+ checkSafeUrl('SideNavigation', href);
return (
-