Skip to content

Dropdown Positioning

SelectContent handles its own positioning. When @floating-ui/vue is installed, the dropdown uses smart positioning that automatically flips and shifts to stay visible within the viewport. Without it, the dropdown falls back to CSS absolute positioning.

Default Positioning

By default, the dropdown opens below the input aligned to the start edge (bottom-start).

Default Positioning

Placement Options

Control where the dropdown appears with the placement prop on SelectContent:

template
<SelectContent placement="bottom-start">
  <!-- ... -->
</SelectContent>

Available placements:

PlacementDescription
bottom-startBelow, aligned to start (default)
bottomBelow, centered
bottom-endBelow, aligned to end
top-startAbove, aligned to start
topAbove, centered
top-endAbove, aligned to end

When @floating-ui/vue is installed, the dropdown automatically flips to the opposite side if there isn't enough room (e.g., bottom-start flips to top-start near the bottom of the viewport).

Floating UI vs CSS Fallback

vue-superselect treats @floating-ui/vue as an optional peer dependency:

  • With @floating-ui/vue installed: Smart positioning with automatic flip and shift. The dropdown measures available space and repositions itself to stay visible.
  • Without @floating-ui/vue: CSS fallback with position: absolute. The dropdown opens at the specified placement and does not reposition.

Install it if you need smart positioning:

sh
npm install @floating-ui/vue
sh
yarn add @floating-ui/vue
sh
pnpm add @floating-ui/vue

No code changes are needed. SelectContent detects the package automatically and switches to smart positioning.

Collision Strategy

When using Floating UI, control how the dropdown handles collisions with the collision-strategy prop:

template
<SelectContent placement="bottom-start" collision-strategy="flip">
  <!-- ... -->
</SelectContent>
StrategyDescription
flipFlip to the opposite side if not enough room (default)
noneStay at the specified placement regardless of available space

Teleport for Overflow Containers

When a select is inside a container with overflow: hidden or overflow: auto, the dropdown gets clipped. Use the teleport prop to render the dropdown outside the container.

Teleport for Overflow Escape

Teleport Options

template
<!-- No teleport (default), dropdown is inline -->
<SelectContent :teleport="false">

<!-- Teleport to body -->
<SelectContent :teleport="true">

<!-- Teleport to a specific selector -->
<SelectContent teleport="#my-container">
ValueBehavior
falseDropdown renders inline (default)
trueDropdown teleports to <body>
"#selector"Dropdown teleports to the specified element

When teleported to <body> with @floating-ui/vue installed, the dropdown remains visually positioned next to the input. It just lives in a different part of the DOM to escape overflow clipping.

Scoped styles and teleport

When using teleport, the dropdown content is rendered outside your component's DOM tree. Scoped styles (<style scoped>) will not apply to teleported content. Use global styles or CSS classes without the scoped attribute for the dropdown.

Force Absolute

The force-absolute prop disables Floating UI positioning and uses plain CSS position: absolute instead:

template
<SelectContent force-absolute>
  <!-- ... -->
</SelectContent>

This is useful when you want the dropdown to be positioned relative to a custom teleport target rather than the input.

Data Attributes for Styling

SelectContent exposes data attributes based on its current position:

css
/* Style based on which side the dropdown opened on */
[data-side="top"] {
  border-bottom: 2px solid var(--brand);
}

[data-side="bottom"] {
  border-top: 2px solid var(--brand);
}
AttributeValues
data-side"top", "bottom", "left", "right"
data-align"start", "center", "end"

Summary

ScenarioConfiguration
Simple dropdownDefault, no props needed
Specific placementplacement="top-start"
Inside scrollable container:teleport="true"
Fixed placement (no flip)collision-strategy="none"
Custom teleport targetteleport="#my-panel"
No Floating UI availableWorks with CSS fallback automatically

Next Steps