use-window-blur-change-title
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

npm-version npm-download

use-window-blur-change-title

React Hook for set the page title when the user is shifting focus away from the current window.

Installation

To install the hook you can use npm:

npm i use-window-blur-change-title

or Yarn if you prefer:

yarn add use-window-blur-change-title

Usage

All you need is simple import the hook:

import { useWindowBlurChangeTitle } from 'use-window-blur-change-title';

And call the hook in the body function component:

useWindowBlurChangeTitle('Hey, please come back');

The hook takes one parameter - the new document title to appear in the blur time of the window. If the user returns to the window (focus), the title will be changed to the one before the change.

Full example:

import { useWindowBlurChangeTitle } from 'use-window-blur-change-title';

export const AppComponent = () => {
  useWindowBlurChangeTitle('Hey, please come back');

  return <div>Hello GitHub!</div>;
};

Package Sidebar

Install

npm i use-window-blur-change-title

Weekly Downloads

0

Version

1.0.6

License

MIT

Unpacked Size

6.5 kB

Total Files

12

Last publish

Collaborators

  • cyntler