Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@emotion/cache docs - added docs section for createCache insertionPoint option #3163

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/khaki-beds-repair.md
@@ -0,0 +1,5 @@
---
'emotion-site': patch
---

@emotion/cache add docs for createCache insertionPoint option
33 changes: 33 additions & 0 deletions packages/cache/README.md
Expand Up @@ -55,8 +55,41 @@ The prefix before class names. It will also be set as the value of the `data-emo

A DOM node that emotion will insert all of its style tags into. This is useful for inserting styles into iframes or windows.

### `insertionPoint`

`Node`

This defines specific dom node after which the rules are inserted into the container. You can use a meta tag to specify the specific location:

```jsx
const head = document.querySelector('head')

// <meta name="emotion-insertion-point" content="">
const emotionInsertionPoint = document.createElement('meta')
emotionInsertionPoint.setAttribute('name', 'emotion-insertion-point')
emotionInsertionPoint.setAttribute('content', '')

head.appendChild(emotionInsertionPoint)

// the emotion sheets should be inserted right after the meta tag
const cache = createCache({
key: 'my-app',
insertionPoint: emotionInsertionPoint
})

function App() {
return (
<CacheProvider value={cache}>
<Main />
</CacheProvider>
)
}
```

### `prepend`

`boolean`

**Deprecated:** Please use `insertionPoint` option instead.

A boolean representing whether to prepend rather than append style tags into the specified container DOM node.