MCPcopy Create free account
hub / github.com/adobe/react-spectrum / AnchorLink

Function AnchorLink

packages/dev/s2-docs/src/typography.tsx:33–63  ·  view source on GitHub ↗
({anchorId, isHovered, level, headingText})

Source from the content-addressed store, hash-verified

31}
32
33function AnchorLink({anchorId, isHovered, level, headingText}) {
34 let {isFocusVisible, focusProps} = useFocusRing({within: true});
35 const href = `#${anchorId}`;
36 return (
37 <span
38 {...focusProps}
39 className={style({
40 position: 'absolute',
41 opacity: {
42 default: 0,
43 isHovered: 1,
44 isFocusVisible: 1
45 },
46 marginStart: {
47 default: 8,
48 level: {
49 3: 4,
50 4: 4
51 }
52 },
53 transition: '[opacity 0.2s ease-in-out]'
54 })({isHovered, isFocusVisible, level})}>
55 <Link href={href} aria-label={`Link to ${headingText}`}>
56 <LinkIcon
57 styles={iconStyle({size: 'S', marginBottom: 4})}
58 UNSAFE_style={{marginBottom: level === 3 || level === 4 ? 0 : undefined}}
59 />
60 </Link>
61 </span>
62 );
63}
64
65const h1 = style({
66 font: 'heading-3xl',

Callers

nothing calls this directly

Calls 2

useFocusRingFunction · 0.90
iconStyleFunction · 0.90

Tested by

no test coverage detected