Skip to content

docs(Elements): format the doc's Usage section #4901

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

Merged
merged 2 commits into from
Jul 24, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
docs(Elements): format the doc's Usage section
  • Loading branch information
pkc918 committed Jul 23, 2025
commit b36945c43cc0d66b8d90472b4784ba4477092298
5 changes: 4 additions & 1 deletion packages/core/useActiveElement/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ Reactive `document.activeElement`

## Usage

```js
```vue
<script setup lang="ts">
import { useActiveElement } from '@vueuse/core'
import { watch } from 'vue'

const activeElement = useActiveElement()

watch(activeElement, (el) => {
console.log('focus changed to', el)
})
</script>
```

## Component Usage
Expand Down
4 changes: 3 additions & 1 deletion packages/core/useDocumentVisibility/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ Reactively track [`document.visibilityState`](https://developer.mozilla.org/en-U

## Usage

```js
```vue
<script setup lang="ts">
import { useDocumentVisibility } from '@vueuse/core'

const visibility = useDocumentVisibility()
</script>
```

## Component Usage
Expand Down
1 change: 1 addition & 0 deletions packages/core/useDropZone/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Due to Safari browser limitations, file type validation is only possible during
```vue
<script setup lang="ts">
import { useDropZone } from '@vueuse/core'
import { ref } from 'vue'

const dropZoneRef = ref<HTMLDivElement>()

Expand Down
6 changes: 6 additions & 0 deletions packages/core/useMutationObserver/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,10 @@ useMutationObserver(el, (mutations) => {
attributes: true,
})
</script>

<template>
<div ref="el">
Hello VueUse
</div>
</template>
```
15 changes: 12 additions & 3 deletions packages/core/useParentElement/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,37 @@ Get parent element of the given element

When no argument is passed, it will return the parent element of the current component.

```js
```vue
<script setup lang="ts">
import { useParentElement } from '@vueuse/core'

const parentEl = useParentElement()

onMounted(() => {
console.log(parentEl.value)
})
</script>
```

It can also accept a `ref` as the first argument.

```ts
```vue
<script setup lang="ts">
import { useParentElement } from '@vueuse/core'
import { shallowRef } from 'vue'

// Don't forget to bind the ref to the element
const tooltip = shallowRef<HTMLElement | undefined>()

const tooltipWrapper = useParentElement(tooltip)

onMounted(() => {
console.log(tooltipWrapper.value)
})
</script>

<template>
<div>
<p ref="tooltip" />
</div>
</template>
```
2 changes: 1 addition & 1 deletion packages/core/useResizeObserver/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Reports changes to the dimensions of an Element's content or the border-box
## Usage

```vue
<script setup>
<script setup lang="ts">
import { useResizeObserver } from '@vueuse/core'
import { ref, useTemplateRef } from 'vue'

Expand Down
8 changes: 7 additions & 1 deletion packages/core/useWindowFocus/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@ Reactively track window focus with `window.onfocus` and `window.onblur` events.

## Usage

```js
```vue
<script setup lang="ts">
import { useWindowFocus } from '@vueuse/core'

const focused = useWindowFocus()
</script>

<template>
<div>{{ focused }}</div>
</template>
```

## Component Usage
Expand Down
18 changes: 15 additions & 3 deletions packages/core/useWindowScroll/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,22 @@ Reactive window scroll

## Usage

```js
```vue
<script setup lang="ts">
import { useWindowScroll } from '@vueuse/core'

const { x, y } = useWindowScroll()
console.log(x.value) // read current x scroll value
y.value = 100 // scroll y to 100
</script>

<template>
<div>
read current x, y scroll: {{ x }}, {{ y }}
</div>
<button @click="x = 100">
scroll X to 100
</button>
<button @click="y = 100">
scroll Y to 100
</button>
</template>
```
11 changes: 10 additions & 1 deletion packages/core/useWindowSize/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,19 @@ Reactive window size

## Usage

```js
```vue
<script setup lang="ts">
import { useWindowSize } from '@vueuse/core'

const { width, height } = useWindowSize()
</script>

<template>
<div>
Width: {{ width }}
Height: {{ height }}
</div>
</template>
```

## Component Usage
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy