René's URL Explorer Experiment


Title: Expose a link's active and pending state as values, not only DOM attributes · Issue #803 · voidzero-dev/void · GitHub

Open Graph Title: Expose a link's active and pending state as values, not only DOM attributes · Issue #803 · voidzero-dev/void

X Title: Expose a link's active and pending state as values, not only DOM attributes · Issue #803 · voidzero-dev/void

Description: Version void 1.8.0, @void/react 1.8.0 Problem Link already works out three things about itself: current: it points to this page, so it gets aria-current="page" and data-void-active. active: with activeMatch="prefix", it points to this pa...

Open Graph Description: Version void 1.8.0, @void/react 1.8.0 Problem Link already works out three things about itself: current: it points to this page, so it gets aria-current="page" and data-void-active. active: with ac...

X Description: Version void 1.8.0, @void/react 1.8.0 Problem Link already works out three things about itself: current: it points to this page, so it gets aria-current="page" and data-void-active. activ...

Opengraph URL: https://github.com/voidzero-dev/void/issues/803

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Expose a link's active and pending state as values, not only DOM attributes","articleBody":"### Version\n\n`void` 1.8.0, `@void/react` 1.8.0\n\n### Problem\n\n`Link` already works out three things about itself:\n\n- **current**: it points to this page, so it gets `aria-current=\"page\"` and `data-void-active`.\n- **active**: with `activeMatch=\"prefix\"`, it points to this page or a parent of it, so it gets `data-void-active`.\n- **pending**: a visit to its destination is loading, so it gets `data-void-pending`.\n\nThat's enough to style the `\u003ca>` itself with CSS. But apps can only read that state as DOM attributes, so anything else has to repeat the matching:\n\n1. **A wrapper that takes the state as a prop.** shadcn's `SidebarMenuButton` renders the link through `render={\u003cLink />}` and styles itself, its icon and its tooltip from an `isActive` prop. `data-void-active` lands on the link, not on a prop.\n2. **Code that isn't a link.** A page header that shows the label of the active sidebar link, a breadcrumb, or a tab bar's sliding indicator all need the active link as a value.\n3. **Content inside the link.** Swapping an icon for a spinner while the link is pending, or a filled icon for an outline one while it's active, needs a CSS selector on the parent for each case.\n\nSo apps write their own check, and it drifts from `Link`'s rules:\n\n```tsx\nimport { Link, useNavigation, useRouter } from '@void/react';\n\n// Ignores the query and doesn't decode the path the way Link does.\nfunction isActive(path: string, href: string, home: string) {\n  return path === href || (href !== home && path.startsWith(`${href}/`));\n}\n\nfunction SidebarItem({ href, label, home }: { href: string; label: string; home: string }) {\n  const { path } = useRouter();\n  const navigation = useNavigation();\n  // Also compares the path only, so it misses the query, the method and the hash.\n  const pending = navigation.state === 'loading' && navigation.location?.pathname === href;\n  return (\n    \u003cSidebarMenuButton isActive={isActive(path, href, home)} render={\u003cLink href={href} />}>\n      {pending ? \u003cSpinner /> : \u003cIcon />}\n      {label}\n    \u003c/SidebarMenuButton>\n  );\n}\n\nfunction PageTitle({ links, home }: { links: { href: string; label: string }[]; home: string }) {\n  const { path } = useRouter();\n  return \u003ch1>{links.find((link) => isActive(path, link.href, home))?.label}\u003c/h1>;\n}\n```\n\n### Proposal\n\n**1. A hook that takes the same values as `Link`.**\n\n```ts\nconst { current, active, pending } = useLinkStatus(href, { method, data, activeMatch });\n```\n\n- `current` is `true` when `Link` would set `aria-current`.\n- `active` is `true` when it would set `data-void-active`.\n- `pending` is `true` when it would set `data-void-pending`.\n\nThe options keep `Link`'s prop names, so the same values go to both. The result would be a `LinkStatus`, named like the `FormStatus` that `useForm()`'s state is built on, with the same `pending`.\n\nEvery adapter's `Link` already passes its router, navigation and resolved link to `linkActiveAttributes()` and `linkPendingAttributes()` from `void/pages-client`. The hook would be a thin wrapper around those two, with no new matching rules:\n\n```ts\nexport function useLinkStatus(href: string, { method, data, activeMatch }: LinkStatusOptions = {}) {\n  const router = useContext(RouterContext);\n  const navigation = useContext(NavigationContext);\n  const link = useMemo(() => resolveLink({ href, method, data }), [href, method, data]);\n  return useMemo(() => {\n    const active = linkActiveAttributes(router, link, activeMatch);\n    return {\n      current: 'aria-current' in active,\n      active: 'data-void-active' in active,\n      pending: 'data-void-pending' in linkPendingAttributes(router, navigation, link),\n    };\n  }, [router, navigation, link, activeMatch]);\n}\n```\n\nThe example above becomes:\n\n```tsx\nfunction SidebarItem({ href, label }: { href: string; label: string }) {\n  const { active, pending } = useLinkStatus(href, { activeMatch: 'prefix' });\n  return (\n    \u003cSidebarMenuButton isActive={active} render={\u003cLink href={href} activeMatch=\"prefix\" />}>\n      {pending ? \u003cSpinner /> : \u003cIcon />}\n      {label}\n    \u003c/SidebarMenuButton>\n  );\n}\n```\n\n**2. A render prop on `Link`'s children** that receives the same object, for content inside the link without the hook's repeated `href`:\n\n```tsx\n\u003cLink href=\"/admin/users\" activeMatch=\"prefix\">\n  {({ active, pending }) => (pending ? \u003cSpinner /> : active ? \u003cUsersFilledIcon /> : \u003cUsersIcon />)}\n\u003c/Link>\n```\n\n**3. A plain function for matching several hrefs at once**, since hooks can't be called in a loop, as `PageTitle` above needs. It would take the router, so it works in any adapter:\n\n```tsx\nimport { isLinkActive } from 'void/pages-client';\n\nfunction PageTitle({ links }: { links: { href: string; label: string }[] }) {\n  const router = useRouter();\n  return \u003ch1>{links.find((link) => isLinkActive(router, link.href, { activeMatch: 'prefix' }))?.label}\u003c/h1>;\n}\n```\n\nThat one is the existing `linkActiveAttributes()` with a boolean result and an `href` instead of a resolved link. `isLinkPending(router, navigation, href)` would match it.\n\nVue, Solid and Svelte would each get (1) and (2) in their own form: a computed ref, an accessor, a store, and a scoped slot or snippet.\n\n### Elsewhere\n\n- **TanStack Router:** `useMatchRoute()` matches any route by `to`, with `fuzzy` for nested routes and `pending: true` for the location being loaded. `Link` passes `{ isActive, isTransitioning }` to its children, and `createLink()` lets a custom component be the link and receive `activeProps`.\n- **React Router:** `useMatch()` matches a pattern, and `NavLink` passes `{ isActive, isPending, isTransitioning }` to `className`, `style` and `children`.\n- **Vue Router:** `useLink()` returns `isActive` and `isExactActive`, the same split as `active` and `current` here.\n- **Next.js:** `useLinkStatus()` returns `{ pending }` inside a `Link`'s children. There's no active state, so apps compare `usePathname()` by hand.\n\n### Scope\n\n(1) covers wrappers and content inside the link; (3) covers matching a list of links; (2) is a convenience over (1). I'd start with (1) and (3), which share all their logic with `Link`, and add (2) if you want it. I'm happy to open a PR, with tests that check each value agrees with `Link`'s attributes for exact, prefix, query, method and pending cases.\n\nFollows up on #676.\n","author":{"url":"https://github.com/karthickeyan-dev","@type":"Person","name":"karthickeyan-dev"},"datePublished":"2026-11-12T10:02:38Z","url":"https://github.com/voidzero-dev/void/issues/803"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:d1cd47f1-37a6-cdce-67d2-1911f4945865
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id95EC:C4D3F:13E9BB:1BC6E9:6AFB8BA2
html-safe-nonce71f4d755af58d1af6479e9494b80a08562bca9fe67444d51755830cb41a3573a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NUVDOkM0RDNGOjEzRTlCQjoxQkM2RTk6NkFGQjhCQTIiLCJ2aXNpdG9yX2lkIjoiNzI3MTEzOTE4ODc2ODczODIxMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac29ac1ed2d7ced54be61584ffbae7bfc90e240f530be437704353208fe147fe10
hovercard-subject-tagissue:6347381022
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/voidzero-dev/void/803/issue_layout
twitter:imagehttps://opengraph.githubassets.com/c73a3945bb9b17716e5c09bd59052a3e8e7f2af2a83026c9aecf26cb1d7df787/voidzero-dev/void/issues/803
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/c73a3945bb9b17716e5c09bd59052a3e8e7f2af2a83026c9aecf26cb1d7df787/voidzero-dev/void/issues/803
og:image:altVersion void 1.8.0, @void/react 1.8.0 Problem Link already works out three things about itself: current: it points to this page, so it gets aria-current="page" and data-void-active. active: with ac...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamekarthickeyan-dev
hostnamegithub.com
expected-hostnamegithub.com
None9694464143465782ecae2a97650b2a2b0708d5c31c74f41ee86da57e315e2735
turbo-cache-controlno-preview
go-importgithub.com/voidzero-dev/void git https://github.com/voidzero-dev/void.git
octolytics-dimension-user_id149750581
octolytics-dimension-user_loginvoidzero-dev
octolytics-dimension-repository_id1164437080
octolytics-dimension-repository_nwovoidzero-dev/void
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1164437080
octolytics-dimension-repository_network_root_nwovoidzero-dev/void
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release05d967182208691fc7f2e6af52e82fa7fabf6bd5
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/voidzero-dev/void/issues/803#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fvoidzero-dev%2Fvoid%2Fissues%2F803
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fvoidzero-dev%2Fvoid%2Fissues%2F803
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=voidzero-dev%2Fvoid
Reloadhttps://github.com/voidzero-dev/void/issues/803
Reloadhttps://github.com/voidzero-dev/void/issues/803
Reloadhttps://github.com/voidzero-dev/void/issues/803
voidzero-devhttps://github.com/voidzero-dev
voidhttps://github.com/voidzero-dev/void
Codehttps://github.com/voidzero-dev/void
Issues31 (31)https://github.com/voidzero-dev/void/issues
Pull requests16 (16)https://github.com/voidzero-dev/void/pulls
Discussionshttps://github.com/voidzero-dev/void/discussions
Actionshttps://github.com/voidzero-dev/void/actions
Security and qualityhttps://github.com/voidzero-dev/void/security
Insightshttps://github.com/voidzero-dev/void/pulse
https://github.com/voidzero-dev/void
New issuehttps://github.com/login?return_to=https://github.com/voidzero-dev/void/issues/803
New issuehttps://github.com/login?return_to=https://github.com/voidzero-dev/void/issues/803
Expose a link's active and pending state as values, not only DOM attributeshttps://github.com/voidzero-dev/void/issues/803#top
https://github.com/karthickeyan-dev
karthickeyan-devhttps://github.com/karthickeyan-dev
on Nov 12, 2026https://github.com/voidzero-dev/void/issues/803#issue-6347381022
#676https://github.com/voidzero-dev/void/issues/676
Sign up for freehttps://github.com/signup?return_to=https://github.com/voidzero-dev/void/issues/803
Sign in to commenthttps://github.com/login?return_to=https://github.com/voidzero-dev/void/issues/803
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.