A lighter but less flexible rendering method, great for when you don't need all the bells and whistles. Tooltips or simple popovers are great usecases for 'css' mode.
position
and transform
. This extra wrapper element can sometimes interfere with your page layout ('js' mode doesn't have this problem).on:open
on:close
and being able to read/manipulate the element visible
state still work as expected, but require Javascript in order to do so.hover
and focus
triggers will actually render using CSS.{#if}
, which means Svelte transitions cannot work.Component | Role | Rendering method | Is focusable | Enter on trigger to open/close | Open/close on focus | Arrow keys move between items | Focus first element | Focus is trapped inside | Escape closes | On close focus is restored to previous element |
---|---|---|---|---|---|---|---|---|---|---|
Tooltip: Can only have text content, without any focusable elements | role="tooltip" | CSS only | no | no | yes | no | no | no | yes (due to losing focus) | n/a |
Popover: Rich content, but without any focusable elements | role="tooltip" | JS | no | yes | no | no | no | no | yes | n/a |
Popover: Rich content which is less important, modeless, and contains focusable elements | role="dialog" | JS | yes | yes | no | no | no | no | yes | yes |
Modal: Rich content which requires an answer or presents important information, contains focusable elements | role="dialog" | JS | yes | yes | no | no | yes | yes | yes | yes |
Menu: Interactive content with focusable elements resembling a classic dropdown menu | role="menu" | JS | yes | yes | no | yes | no | no | yes | yes |