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.

Z-Index

Skeleton does not take an opinionated stance regarding z-index stacking. This means elements may be occluded beneath other elements with a higher index. Adjust this using the zIndex component property.

<Popover ... zIndex={10}>
<!-- ... -->
</Popover>

Popover

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

Anatomy

<Popover>
<div>
trigger
<div>
positioner
<div>
arrow
<div>
content
<div>

API Reference

Popover

Property Type Description
arrow
boolean
Enable display of the popover arrow.
zIndex
string
Set z-index for the positioner.
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.
triggerAriaLabel
string
Set the aria-label for the trigger.
positionerBase
string
Set base 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.
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.
autoFocus
boolean
Whether to automatically set focus on the first focusable content within the popover when opened.
Default: true
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
open
boolean
The controlled open state of the popover
defaultOpen
boolean
The initial open state of the popover when rendered. Use when you don't need to control the open state of the popover.
positioning
The user provided options used to position the popover content
onOpenChange
Function invoked when the popover opens or closes
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
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
onEscapeKeyDown
Function called when the escape key is pressed
persistentElements
Returns the persistent elements that: - should not have pointer-events disabled - should not trigger the dismiss event
portalled
boolean
Whether the popover is portalled. This will proxy the tabbing behavior regardless of the DOM position of the popover content.
Default: true

Tooltip

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

Anatomy

<Tooltip>
<div>
trigger
<div>
positioner
<div>
arrow
<div>
content
<div>

API Reference

Tooltip

Property Type Description
arrow
boolean
Enable display of the popover arrow.
zIndex
string
Set z-index for the positioner.
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.
triggerAriaLabel
string
Set the aria-label for the trigger.
positionerBase
string
Set base 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.
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 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.
disabled
boolean
Whether the tooltip is disabled
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.
aria-label
string
Custom label for the tooltip.
open
boolean
The controlled open state of the tooltip
defaultOpen
boolean
The initial open state of the tooltip when rendered. Use when you don't need to control the open state of the tooltip.
positioning
The user provided options used to position the popover content
onOpenChange
Function called when the tooltip is opened.
closeOnEscape
boolean
Whether to close the tooltip when the Escape key is pressed.
Default: true
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
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

Combobox

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

Anatomy

<Combobox>
<div>
label
<div>
labelText
<div>
inputGroup
<div>
inputGroupInput
<div>
inputGroupButton
<div>
inputGroupArrow
<div>
positioner
<div>
content
<div>
option
<div>

API Reference

Combobox

Property Type Description
data
Provide the list of label and value data
label
string
Set the label to display.
zIndex
string
Set z-index for the positioner.
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.
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.
item
Snippet<[T]>
Provide a custom template for the option.
onclick
Handle the combobox dropdown button click event.
ids
The ids of the elements in the combobox. Useful for composition.
multiple
boolean
Whether to allow multiple selection. **Good to know:** When `multiple` is `true`, the `selectionBehavior` is automatically set to `clear`. It is recommended to render the selected items in a separate container.
value
The controlled value of the combobox's selected items
defaultValue
The initial value of the combobox's selected items when rendered. Use when you don't need to control the value of the combobox's selected items.
Default: []
disabled
boolean
Whether the combobox is disabled
onValueChange
Function called when a new item is selected
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.
name
string
The `name` attribute of the combobox's input. Useful for form submission
translations
Specifies the localized strings that identifies the accessibility elements and their states
required
boolean
Whether the combobox is required
invalid
boolean
Whether the combobox is invalid
form
string
The associate form of the combobox.
readOnly
boolean
Whether the combobox is readonly. This puts the combobox in a "non-editable" mode but the user can still interact with it
autoFocus
boolean
Whether to autofocus the input on mount
loopFocus
boolean
Whether to loop the keyboard navigation through the items
Default: true
composite
boolean
Whether the combobox is a composed with other composite widgets like tabs
Default: true
navigate
Function to navigate to the selected item
inputValue
string
The controlled value of the combobox's input
defaultInputValue
string
The initial value of the combobox's input when rendered. Use when you don't need to control the value of the combobox's input.
Default: ""
onInputValueChange
Function called when the input's value changes
onHighlightChange
Function called when an item is highlighted using the pointer or keyboard navigation.
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
open
boolean
The controlled open state of the combobox
defaultOpen
boolean
The initial open state of the combobox when rendered. Use when you don't need to control the open state of the combobox.
placeholder
string
The placeholder text of the combobox's input
defaultHighlightedValue
string
The initial highlighted value of the combobox when rendered. Use when you don't need to control the highlighted value of the combobox.
highlightedValue
string
The controlled highlighted value of the combobox
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"
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
positioning
The positioning options to dynamically position the menu
Default: { placement: "bottom-start" }
onOpenChange
Function called when the popup is opened
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
disableLayer
boolean
Whether to disable registering this a dismissable layer

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

Anatomy

<Modal>
<div>
trigger
<div>
backdrop
<div>
positioner
<div>
content
<div>

API Reference

Modal

Property Type Description
base
string
Set base classes for the root element.
classes
string
Provide arbitrary classes for the root element.
zIndex
string
Set z-index for the positioner.
triggerBase
string
Set base classes for the trigger.
triggerBackground
string
Set background classes for the trigger.
triggerClasses
string
Provide arbitrary classes for the trigger.
triggerAriaLabel
string
Set the aria-label 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.
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.
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.
aria-label
string
Human readable label for the dialog, in event the dialog title is not rendered
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
open
boolean
The controlled open state of the dialog
defaultOpen
boolean
The initial open state of the dialog when rendered. Use when you don't need to control the open state of the dialog.
Default: false
onOpenChange
Function to call when the dialog's open state changes
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
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
role
"dialog" | "alertdialog"
The dialog's role
Default: "dialog"
onEscapeKeyDown
Function called when the escape key is pressed
persistentElements
Returns the persistent elements that: - should not have pointer-events disabled - should not trigger the dismiss event

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.