Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
docs: add copy-to-clipboard on heading anchor click
Clicking a section heading now copies the full URL with anchor to the clipboard and shows a brief checkmark confirmation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sushmithamallesh committed
Feb 9, 2026 at 16:28 UTC
7dfe69150e95b13c28563d32ef58cd6c9c5fcaf2
2 files changed
+64
docs/components/heading.tsx
new
+60
@@ -0,0 +1,60 @@
1
+'use client';
2
+
3
+import { cn } from '@fumadocs/ui/cn';
4
+import { Link, Check } from 'lucide-react';
5
+import { useState, type ComponentPropsWithoutRef } from 'react';
6
+
7
+type HeadingProps = ComponentPropsWithoutRef<'h1'> & {
8
+ as?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
9
+};
10
+
11
+export function Heading({ as, className, ...props }: HeadingProps) {
12
+ const As = as ?? 'h1';
13
+
14
+ if (!props.id) return <As className={className} {...props} />;
15
+
16
+ return (
17
+ <As
18
+ className={cn(
19
+ 'flex scroll-m-28 flex-row items-center gap-2',
20
+ className,
21
+ )}
22
+ {...props}
23
+ >
24
+ <HeadingAnchor id={props.id}>{props.children}</HeadingAnchor>
25
+ </As>
26
+ );
27
+}
28
+
29
+function HeadingAnchor({ id, children }: { id: string; children: React.ReactNode }) {
30
+ const [copied, setCopied] = useState(false);
31
+
32
+ const handleClick = (e: React.MouseEvent<HTMLAnchorElement>) => {
33
+ e.preventDefault();
34
+ const url = `${window.location.origin}${window.location.pathname}#${id}`;
35
+ window.history.replaceState(null, '', `#${id}`);
36
+ navigator.clipboard.writeText(url).then(() => {
37
+ setCopied(true);
38
+ setTimeout(() => setCopied(false), 2000);
39
+ });
40
+ };
41
+
42
+ return (
43
+ <>
44
+ <a data-card="" href={`#${id}`} className="peer" onClick={handleClick}>
45
+ {children}
46
+ </a>
47
+ {copied ? (
48
+ <Check
49
+ aria-hidden
50
+ className="size-3.5 shrink-0 text-green-500 transition-opacity"
51
+ />
52
+ ) : (
53
+ <Link
54
+ aria-hidden
55
+ className="size-3.5 shrink-0 text-fd-muted-foreground opacity-0 transition-opacity peer-hover:opacity-100"
56
+ />
57
+ )}
58
+ </>
59
+ );
60
+}
docs/mdx-components.tsx
+4
@@ -1,5 +1,6 @@
1
import defaultMdxComponents from 'fumadocs-ui/mdx';
2
import type { MDXComponents } from 'mdx/types';
3
+import { Heading } from '@/components/heading';
4
import { YouTube } from '@/components/youtube';
5
import { Tabs, Tab, TabsList, TabsTrigger, TabsContent } from 'fumadocs-ui/components/tabs';
6
import { Accordion, Accordions } from 'fumadocs-ui/components/accordion';
@@ -35,6 +36,9 @@ import {
36
export function getMDXComponents(components?: MDXComponents): MDXComponents {
37
return {
38
...defaultMdxComponents,
39
+ h2: (props) => <Heading as="h2" {...props} />,
40
+ h3: (props) => <Heading as="h3" {...props} />,
41
+ h4: (props) => <Heading as="h4" {...props} />,
42
img: (props) => <ImageZoom {...(props as any)} />,
43
YouTube,
44
Tabs,