Lonely Tab Title

Changes the page title to a custom message when the user switches away from the tab. Uses the Page Visibility API.

Component

<LonelyTabTitle /><LonelyTabTitle text="Come back! 😢" />

Installation

pnpm dlx shadcn@latest add "https://pulkitxm.com/components/lonely-tab-title.json"

Usage

Import

Add the LonelyTabTitle import.

import { LonelyTabTitle } from "@/components/lonely-tab-title";

Use

Add to your root layout.

<LonelyTabTitle />;

Guidelines

  • Add to root layout (e.g. app/layout.tsx) for site-wide effect.
  • Renders nothing; only listens for visibilitychange events.
  • Restores the original title when the user returns to the tab.
  • Use the text prop to customize the message shown when the tab is hidden.

Props

All props are optional unless marked required. Use these to customize every aspect of the component.

PropTypeDefaultDescription
textstring"I am a lonely tab!!"Title to show when the user switches away from the tab.

Examples

Basic

Add to your root layout. When you switch tabs, the title becomes 'I am a lonely tab!!'.

<LonelyTabTitle /><LonelyTabTitle text="Come back! 😢" />
import { LonelyTabTitle } from "@/components/lonely-tab-title";

<LonelyTabTitle />;

Custom text

Custom message when the user leaves the tab.

<LonelyTabTitle /><LonelyTabTitle text="Come back! 😢" />
import { LonelyTabTitle } from "@/components/lonely-tab-title";

<LonelyTabTitle text="Come back! 😢" />;

Last updated on Mar 10

Made with ❤️ by Pulkit & Cursor :)

© 2026 Pulkit. All rights reserved

DMCA Verified

Last updated: