# createVirtual API

> Auto-generated API reference for `createVirtual` from @vuetify/v0 (Vuetify0).
> Source of truth: https://0.vuetifyjs.com/api/create-virtual

## Related

- https://0.vuetifyjs.com/composables/data/create-virtual
- https://0.vuetifyjs.com/composables/data/create-filter
- https://0.vuetifyjs.com/composables/semantic/create-overflow

## Functions

### createVirtual

```ts
(items: Ref<readonly T[], readonly T[]>, _options?: VirtualOptions) => VirtualContext<T>
```

### createVirtualContext

Creates a virtual scrolling context with dependency injection support.

```ts
(items: Ref<readonly T[], readonly T[]>, _options?: VirtualContextOptions) => ContextTrinity<VirtualContext<T>>
```

### useVirtual

Returns the current virtual context from dependency injection.

```ts
(namespace?: string) => VirtualContext<T>
```

## Options

| Name | Type | Default | Required | Description |
|---|---|---|---|---|
| `itemHeight` | `string \| number \| null \| undefined` | — | no | The height of the item. |
| `height` | `string \| number \| undefined` | — | no | The height of the container. |
| `overscan` | `number \| undefined` | — | no | The number of extra items to render. |
| `direction` | `VirtualDirection \| undefined` | — | no | The direction of the scrolling. |
| `anchor` | `VirtualAnchor \| undefined` | — | no | The anchor of the scrolling. |
| `anchorSmooth` | `boolean \| undefined` | — | no | Whether to smooth the anchor position. |
| `onStartReached` | `((distance: number) => void \| Promise<void>) \| undefined` | — | no | The callback to call when the start is reached. |
| `onEndReached` | `((distance: number) => void \| Promise<void>) \| undefined` | — | no | The callback to call when the end is reached. |
| `startThreshold` | `number \| undefined` | — | no | The threshold for the start. |
| `endThreshold` | `number \| undefined` | — | no | The threshold for the end. |
| `momentum` | `boolean \| undefined` | — | no | Whether to enable momentum scrolling. |
| `elastic` | `boolean \| undefined` | — | no | Whether to enable elastic scrolling. |

## Methods

| Name | Type | Description |
|---|---|---|
| `scrollTo` | `(index: number, options?: ScrollToOptions) => void` | Scroll to an item by index. |
| `scroll` | `() => void` | The scroll event handler. |
| `scrollend` | `() => void` | The scrollend event handler. |
| `resize` | `(index: number, height: number) => void` | Resize an item by index. |
| `reset` | `() => void` | Reset the virtualized items. |

## Properties

| Name | Type | Description |
|---|---|---|
| `element` | `Ref<HTMLElement \| undefined, HTMLElement \| undefined>` | The element that is being virtualized. |
| `items` | `ComputedRef<VirtualItem<T>[]>` | The items that are being virtualized. |
| `offset` | `Readonly<ShallowRef<number>>` | The offset of the virtualized items. |
| `size` | `Readonly<ShallowRef<number>>` | The size of the virtualized items. |
| `state` | `ShallowRef<VirtualState>` | The state of the virtualized items. |
