Skip to content

Commit dc8a436

Browse files
jasonrueschclaude
andcommitted
feat: add viewTransition to internal Link navigation
Apply React Router's viewTransition to all internal-navigation links. Wrapper components (AppLink, Button, Card) set it as an overridable default before the prop spread; direct Link/NavLink usages set it inline. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent c4e3ee9 commit dc8a436

8 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/app/_components/app-link.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export function AppLink(props: AppLinkProps) {
5656
"className" | "children"
5757
>;
5858
return (
59-
<Link to={to} {...linkRest} className={merged}>
59+
<Link to={to} viewTransition {...linkRest} className={merged}>
6060
{content}
6161
</Link>
6262
);

src/app/_components/button.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export function Button(props: ButtonProps) {
8080
"className" | "children"
8181
>;
8282
return (
83-
<Link to={to} {...linkRest} className={merged}>
83+
<Link to={to} viewTransition {...linkRest} className={merged}>
8484
{children}
8585
</Link>
8686
);

src/app/_components/card.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export function Card(props: CardProps) {
4343
"className" | "children"
4444
>;
4545
return (
46-
<Link to={to} {...linkRest} className={merged}>
46+
<Link to={to} viewTransition {...linkRest} className={merged}>
4747
{strip}
4848
{children}
4949
</Link>

src/app/_components/header.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export function Header() {
6161

6262
<Link
6363
to="/"
64+
viewTransition
6465
className="flex items-center gap-2 text-base font-semibold tracking-tight"
6566
>
6667
<img src="/logo.svg" alt="" aria-hidden="true" className="h-7 w-7" />
@@ -95,6 +96,7 @@ export function Header() {
9596
<RRNavLink
9697
to={item.to}
9798
end={item.end}
99+
viewTransition
98100
className={({ isActive }) =>
99101
[
100102
"block rounded-lg px-3 py-2 text-base font-medium transition-colors",

src/app/packages/layout.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export default function PackagesLayout() {
2121
<NavLink
2222
to="/packages"
2323
end
24+
viewTransition
2425
className={({ isActive }) =>
2526
[
2627
"block rounded-lg px-3 py-2",
@@ -36,6 +37,7 @@ export default function PackagesLayout() {
3637
<NavLink
3738
key={pkg.href}
3839
to={pkg.href}
40+
viewTransition
3941
className={({ isActive }) =>
4042
[
4143
"block rounded-lg px-3 py-2 font-mono text-xs",

src/app/packages/page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export default function PackagesIndex() {
2929
<li key={pkg.href}>
3030
<Link
3131
to={pkg.href}
32+
viewTransition
3233
className="group relative block overflow-hidden rounded-2xl bg-white p-6 ring-1 ring-zinc-200 transition hover:-translate-y-0.5 hover:shadow-lg dark:bg-zinc-900 dark:ring-zinc-800"
3334
>
3435
<div

src/app/packages/react-router-next/not-found.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export default function ExampleNotFound() {
1919
</p>
2020
<Link
2121
to="/packages/react-router-next"
22+
viewTransition
2223
className="bg-brand-600 hover:bg-brand-700 mt-5 inline-block rounded-full px-4 py-2 text-sm font-medium text-white"
2324
>
2425
Back to examples

src/app/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,14 @@ export default function Home() {
6161
<div className="mt-10 flex flex-wrap gap-3">
6262
<Link
6363
to="/services"
64+
viewTransition
6465
className="text-brand-700 rounded-full bg-white px-5 py-2.5 text-sm font-semibold shadow-sm hover:bg-zinc-100"
6566
>
6667
Explore services
6768
</Link>
6869
<Link
6970
to="/packages"
71+
viewTransition
7072
className="rounded-full bg-white/10 px-5 py-2.5 text-sm font-semibold text-white ring-1 ring-white/30 ring-inset hover:bg-white/20"
7173
>
7274
Open source

0 commit comments

Comments
 (0)