# useFloating

`useFloating(reference, floating, options)` places a floating element next to a reference
element, for example a list of options under an input. The position updates on scroll and
resize.

`placement` sets the side and alignment, for example `bottom-start`, and `offset` the distance in
pixels. When there is not enough room, the element moves to the opposite side. `arrow` is the
arrow element, which the composable points at the reference element.

## Signature

```ts
import { useFloating } from '@numior/kit';

useFloating: (reference: MaybeRefOrGetter<HTMLElement | null | undefined>, floating: MaybeRefOrGetter<HTMLElement | null | undefined>, options?: FloatingOptions) => void
```

```ts
import type { FloatingOptions } from '@numior/kit';

interface FloatingOptions {
  readonly placement?: MaybeRefOrGetter<FloatingPlacement | undefined>;
  readonly offset?: MaybeRefOrGetter<number | undefined>;
  readonly arrow?: MaybeRefOrGetter<HTMLElement | null | undefined>;
  readonly size?: MaybeRefOrGetter<FloatingSize | undefined>;
  readonly enabled?: MaybeRefOrGetter<boolean | undefined>;
  readonly strategy?: FloatingStrategy | undefined;
}
```

## Usage

```ts
import { useFloating } from '@numior/kit';

useFloating(trigger, panel, {
  placement: 'bottom-start',
  offset: 8,
  size: { matchWidth: true, fitHeight: true },
  enabled: () => open.value,
});
```

`size.matchWidth` makes the element at least as wide as the reference, and `size.fitHeight`
limits its height to the free space in the window. `size.fitWidth` limits its width the same way,
and `maxBlockSize` and `maxInlineSize` set a cap in pixels. `enabled` turns the positioning on
while the element is open.

By default the element uses `position: fixed`, so a parent with `overflow: hidden` does not clip
it. `strategy: 'absolute'` uses `position: absolute` instead.
