Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

React components will manage your changes to the document head

License

NotificationsYou must be signed in to change notification settings

uiwjs/react-head

Repository files navigation

Usingmy app is also a way tosupport me:
KeyzerVidwall HubVidCropVidwallMousio HintMousioMusicerAudioerFileSentinelFocusCursorVideoerKeyClickerDayBarIconedMousioQuick RSSQuick RSSWeb ServeCopybook GeneratorDevTutor for SwiftUIRegexMateTime PassageIconize FolderTextsound SaverCreate Custom SymbolsDevHubResume RevisePalette GeniusSymbol Scribe

react-head

Buy me a coffeeCInpm versionNPM DownloadsCoverage Status

React components will manage your changes to the document head, likereact-helmet

Quick Start

npm install @uiw/react-head

Using

importReact,{useState}from"react";importHeadfrom'@uiw/react-head';exportdefaultfunctionApp(){const[count,setCount]=useState(1);constclick=()=>setCount(count+1)return(<divclassName="container"><Head><Head.MetacharSet="utf-8"/><Head.Title>{count} React Head</Head.Title><Head.Linkrel="canonical"href="https://uiwjs.github.io"/></Head><buttononClick={click}>        Switch Title - "{count}"</button></div>);}

Style

importReact,{useState}from"react";importHeadfrom'@uiw/react-head';constcss=`.box-test { color: red; }`exportdefaultfunctionApp(){return(<div><Head.Style>{css}</Head.Style><Head><Head.Style>{css}</Head.Style></Head><divclassName="box-test">Text Color</div></div>);}

outputs:

<head><style>.box-test {color: red; }</style><style>.box-test {color: red; }</style></head><!-- .... -->

Meta

importReact,{useState}from"react";importHeadfrom'@uiw/react-head';exportdefaultfunctionApp(){const[count,setCount]=useState(1);constclick=()=>setCount(count+1)return(<div><Head.Metaname="keywords"content="react-head,uiw,uiwjs"/><Head.MetacharSet="utf-8"/><Head.Metaname="description"content={`${count} React components will manage your changes to the document head.`}/><buttononClick={click}>        Modify Meta name=description - "{count}"</button></div>);}

Outputs:

<head><metaname="keywords"content="react-head,uiw,uiwjs"><metaname="description"content="1 React components will manage your changes to the document head."></head>

Modify Favicon

<Head.Linkrel="icon"href="/favicon.ico"/><Head.Linkrel="icon"type="image/svg+xml"href="/favicon.svg"/>
importReact,{useState}from"react";importHeadfrom'@uiw/react-head';constfavicon=`data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🦖</text></svg>`constfavicon2=`data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🤡</text></svg>`exportdefaultfunctionApp(){const[show,setShow]=useState(false);return(<div><Head.Linkrel="icon"type="image/svg+xml"href={show ?favicon :favicon2}/><buttononClick={()=>setShow(!show)}>        Change Favicon{show ?"🦖" :"🤡"}{String(show)}</button></div>);}

Outputs:

<head><linkdata-head="true"rel="icon"href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🤡</text></svg>"/></head>

All Sub Components

Elements that can be used inside the<head>:

Development

  1. Dependencies in the installation package and example
npm install
  1. To develop, run the self-reloading build:
npm run build# Compile packages      📦 @uiw/react-headnpm run watch# Real-time compilation 📦 @uiw/react-head
  1. Run Document Website Environment:
npm run start
  1. To contribute, please fork repos, add your patch and tests for it (in thetest/ folder) and submit a pull request.
npm runtest

Contributors

As always, thanks to our amazing contributors!

Made withcontributors.

License

Licensed under the MIT License.

About

React components will manage your changes to the document head

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors3

  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp