Popover - Skeleton

  1. integrations
  2. popover
  3. svelte

Popover

Learn how to integrate dynamic and interactive popover interfaces.

Floating UI Svelte

Please note this section will be the future home of the Floating UI Svelte integrateion guide, an upcoming open-source library from Skeleton Labs. While this project is in development, we have provided several Svelte-specific components to act as temporary substitutions. Note that these components will remain available until our next major release (Skeleton v4.x). However, the goal will be to replace these with Floating UI Svelte as soon as possible.

Components

Popover

Triggers an anchored popover when you click the trigger element. View API Reference.

Tooltip

Triggers an anchored popover when you hover the trigger element. View API Reference.

Combobox

Triggers an anchored popover list when you tap the arrow. Includes auto-suggestion via typeahead. View API Reference.

Generate modals or dialogs that require a user’s immediate attention. View API Reference.

Native Browser APIs

Skeleton will always favor native browser APIs over third-party libraries such as Floating UI Svelte. The following is a list of current and upcoming incoming APIs we will aim to support in the future, but are not quite standardized cross-browser yet.

API Reference

Popover

Property Type Description
open
boolean
Set the open state of the popover.
arrow
boolean
Enable display of the popover arrow.
base
string
Set base classes for the root element.
classes
string
Provide arbitrary classes for the root element.
triggerBase
string
Set base classes for the trigger.
triggerBackground
string
Set background classes for the trigger.
triggerClasses
string
Provide arbitrary classes for the trigger.
positionerBase
string
Set base classes for the positioner.
positionerZIndex
string
Set z-index classes for the positioner.
positionerClasses
string
Provide arbitrary classes for the positioner.
contentBase
string
Set base classes for the content.
contentBackground
string
Set background classes for the content.
contentClasses
string
Provide arbitrary classes for the content.
arrowBase
string
Set base classes for the arrow.
arrowBackground
string
Set background classes for the arrow.
arrowClasses
string
Provide arbitrary classes for the arrow.
trigger
Snippet<[]>
Provide the template contents inside the trigger button.
content
Snippet<[]>
Provide the template contents of the popover itself.
onclick
Handle the popover button click event.
ids
The ids of the elements in the popover. Useful for composition.
modal
boolean
Whether the popover should be modal. When set to `true`: - interaction with outside elements will be disabled - only popover content will be visible to screen readers - scrolling is blocked - focus is trapped within the popover
Default: false
portalled
boolean
Whether the popover is portalled. This will proxy the tabbing behavior regardless of the DOM position of the popover content.
Default: true
autoFocus
boolean
Whether to automatically set focus on the first focusable content within the popover when opened.
Default: true
initialFocusEl
The element to focus on when the popover is opened.
closeOnInteractOutside
boolean
Whether to close the popover when the user clicks outside of the popover.
Default: true
closeOnEscape
boolean
Whether to close the popover when the escape key is pressed.
Default: true
onOpenChange
Function invoked when the popover opens or closes
positioning
The user provided options used to position the popover content
open.controlled
boolean
Whether the popover is controlled by the user
getRootNode
A root node to correctly resolve document in custom environments. E.x.: Iframes, Electron.
dir
"ltr" | "rtl"
The document's text/writing direction.
Default: "ltr"
onEscapeKeyDown
Function called when the escape key is pressed
onPointerDownOutside
Function called when the pointer is pressed down outside the component
onFocusOutside
Function called when the focus is moved outside the component
onInteractOutside
Function called when an interaction happens outside the component
persistentElements
Returns the persistent elements that: - should not have pointer-events disabled - should not trigger the dismiss event

Tooltip

Property Type Description
open
boolean
Set the open state of the tooltip.
base
string
Set base classes for the root element.
classes
string
Provide arbitrary classes for the root element.
triggerBase
string
Set base styles for the trigger.
triggerBackground
string
Set background styles for the trigger.
triggerClasses
string
Provide arbitrary styles for the trigger.
positionerBase
string
Set base classes for the positioner.
positionerZIndex
string
Set z-index classes for the positioner.
positionerClasses
string
Provide arbitrary classes for the positioner.
contentBase
string
Set base styles for the content.
contentBackground
string
Set background styles for the content.
contentClasses
string
Provide arbitrary styles for the content.
trigger
Snippet<[]>
Provide the template contents inside the trigger button.
content
Snippet<[]>
Provide the template contents of the tooltip itself.
onmouseover
Handle the tooltip button hover event.
onclick
Handle the tooltip button click event.
ids
The ids of the elements in the tooltip. Useful for composition.
openDelay
number
The open delay of the tooltip.
Default: 1000
closeDelay
number
The close delay of the tooltip.
Default: 500
closeOnPointerDown
boolean
Whether to close the tooltip on pointerdown.
Default: true
closeOnEscape
boolean
Whether to close the tooltip when the Escape key is pressed.
Default: true
closeOnScroll
boolean
Whether the tooltip should close on scroll
Default: true
closeOnClick
boolean
Whether the tooltip should close on click
Default: true
interactive
boolean
Whether the tooltip's content is interactive. In this mode, the tooltip will remain open when user hovers over the content.
Default: false
onOpenChange
Function called when the tooltip is opened.
aria-label
string
Custom label for the tooltip.
positioning
The user provided options used to position the popover content
disabled
boolean
Whether the tooltip is disabled
open.controlled
boolean
Whether the tooltip is controlled by the user
dir
"ltr" | "rtl"
The document's text/writing direction.
Default: "ltr"
getRootNode
A root node to correctly resolve document in custom environments. E.x.: Iframes, Electron.

Combobox

Property Type Description
data
Provide the list of label and value data
value
Bind the selected value.
label
string
Set the label to display.
base
string
Set base classes for the root element.
width
string
Set width classes for the root element.
classes
string
Provide arbitrary classes for the root element.
labelBase
string
Set base classes for the label.
labelText
string
Set text and font classes for the label.
labelClasses
string
Provide arbitrary classes for the label.
inputGroupBase
string
Set base classes for the input group.
inputGroupInput
string
Set input classes for the input group.
inputGroupButton
string
Set button classes for the input group.
inputGroupArrow
string
Set arrow classes for the input group.
inputGroupClasses
string
Provide arbitrary classes for the input group.
positionerBase
string
Set base classes for the positioner.
positionerZIndex
string
Set z-index classes for the positioner.
positionerClasses
string
Provide arbitrary classes for the positioner.
contentBase
string
Set base classes for the content.
contentBackground
string
Set background classes for the content.
contentSpaceY
string
Set space-y classes for the content.
contentClasses
string
Provide arbitrary classes for the content.
optionBase
string
Set base classes for the option.
optionFocus
string
Set focus classes for the option.
optionHover
string
Set hover classes for the option.
optionActive
string
Set active classes for the option.
optionClasses
string
Provide arbitrary classes for the option.
arrow
Snippet<[]>
Provide a custom arrow icon.
onclick
Handle the combobox dropdown button click event.
open
boolean
Whether the combobox is open
open.controlled
boolean
Whether the combobox open state is controlled by the user
ids
The ids of the elements in the combobox. Useful for composition.
inputValue
string
The current value of the combobox's input
name
string
The `name` attribute of the combobox's input. Useful for form submission
form
string
The associate form of the combobox.
disabled
boolean
Whether the combobox is disabled
readOnly
boolean
Whether the combobox is readonly. This puts the combobox in a "non-editable" mode but the user can still interact with it
invalid
boolean
Whether the combobox is invalid
required
boolean
Whether the combobox is required
placeholder
string
The placeholder text of the combobox's input
highlightedValue
string
The active item's id. Used to set the `aria-activedescendant` attribute
inputBehavior
"autohighlight" | "autocomplete" | "none"
Defines the auto-completion behavior of the combobox. - `autohighlight`: The first focused item is highlighted as the user types - `autocomplete`: Navigating the listbox with the arrow keys selects the item and the input is updated
Default: "none"
selectionBehavior
"clear" | "replace" | "preserve"
The behavior of the combobox input when an item is selected - `replace`: The selected item string is set as the input value - `clear`: The input value is cleared - `preserve`: The input value is preserved
Default: "replace"
autoFocus
boolean
Whether to autofocus the input on mount
openOnClick
boolean
Whether to open the combobox popup on initial click on the input
Default: false
openOnChange
boolean | ((details: InputValueChangeDetails) => boolean)
Whether to show the combobox when the input value changes
Default: true
allowCustomValue
boolean
Whether to allow typing custom values in the input
loopFocus
boolean
Whether to loop the keyboard navigation through the items
Default: true
positioning
The positioning options to dynamically position the menu
onInputValueChange
Function called when the input's value changes
onValueChange
Function called when a new item is selected
onHighlightChange
Function called when an item is highlighted using the pointer or keyboard navigation.
onOpenChange
Function called when the popup is opened
translations
Specifies the localized strings that identifies the accessibility elements and their states
closeOnSelect
boolean
Whether to close the combobox when an item is selected.
openOnKeyPress
boolean
Whether to open the combobox on arrow key press
Default: true
scrollToIndexFn
Function to scroll to a specific index
composite
boolean
Whether the combobox is a composed with other composite widgets like tabs
Default: true
disableLayer
boolean
Whether to disable registering this a dismissable layer
dir
"ltr" | "rtl"
The document's text/writing direction.
Default: "ltr"
getRootNode
A root node to correctly resolve document in custom environments. E.x.: Iframes, Electron.
onPointerDownOutside
Function called when the pointer is pressed down outside the component
onFocusOutside
Function called when the focus is moved outside the component
onInteractOutside
Function called when an interaction happens outside the component

Modal

Property Type Description
open
boolean
Set the open state of the dialog.
base
string
Set base classes for the root element.
classes
string
Provide arbitrary classes for the root element.
triggerBase
string
Set base classes for the trigger.
triggerBackground
string
Set background classes for the trigger.
triggerClasses
string
Provide arbitrary classes for the trigger.
backdropBase
string
Set base classes for the backdrop.
backdropBackground
string
Set background classes for the backdrop.
backdropClasses
string
Provide arbitrary classes for the backdrop.
positionerBase
string
Set base classes for the positioner.
positionerDisplay
string
Set display classes for the positioner.
positionerJustify
string
Set justify classes for the positioner.
positionerAlign
string
Set align classes for the positioner.
positionerPadding
string
Set padding classes for the positioner.
positionerZIndex
string
Set z-index classes for the positioner.
positionerClasses
string
Provide arbitrary classes for the positioner.
contentBase
string
Set base classes for the content.
contentBackground
string
Set background classes for the content.
contentClasses
string
Provide arbitrary classes for the content.
transitionsBackdropIn
Provide transition for backdrop in
transitionsBackdropOut
Provide transition for backdrop out
transitionsPositionerIn
Provide transition for dialog in
transitionsPositionerOut
Provide transition for dialog out
trigger
Snippet<[]>
Provide the template contents inside the trigger button.
content
Snippet<[]>
Provide the template contents of the dialog itself.
onclick
Handle the dialog button click event.
ids
The ids of the elements in the dialog. Useful for composition.
trapFocus
boolean
Whether to trap focus inside the dialog when it's opened
Default: true
preventScroll
boolean
Whether to prevent scrolling behind the dialog when it's opened
Default: true
modal
boolean
Whether to prevent pointer interaction outside the element and hide all content below it
Default: true
initialFocusEl
Element to receive focus when the dialog is opened
finalFocusEl
Element to receive focus when the dialog is closed
restoreFocus
boolean
Whether to restore focus to the element that had focus before the dialog was opened
onOpenChange
Callback to be invoked when the dialog is opened or closed
closeOnInteractOutside
boolean
Whether to close the dialog when the outside is clicked
Default: true
closeOnEscape
boolean
Whether to close the dialog when the escape key is pressed
Default: true
aria-label
string
Human readable label for the dialog, in event the dialog title is not rendered
role
"dialog" | "alertdialog"
The dialog's role
Default: "dialog"
open.controlled
boolean
Whether the dialog is controlled by the user
dir
"ltr" | "rtl"
The document's text/writing direction.
Default: "ltr"
getRootNode
A root node to correctly resolve document in custom environments. E.x.: Iframes, Electron.
onEscapeKeyDown
Function called when the escape key is pressed
onPointerDownOutside
Function called when the pointer is pressed down outside the component
onFocusOutside
Function called when the focus is moved outside the component
onInteractOutside
Function called when an interaction happens outside the component
persistentElements
Returns the persistent elements that: - should not have pointer-events disabled - should not trigger the dismiss event