npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

sv-bootstrap-dropdown

v1.0.3

Published

Bootstrap 5 dropdown component for Svelte 5

Readme

sv-bootstrap-dropdown

Bootstrap 5 dropdown component for Svelte 5. Built on Popper.js v2 for dynamic positioning.

Install

npm install sv-bootstrap-dropdown

Bootstrap CSS must be present globally in your project.

Usage

Single button

<script>
  import Dropdown from 'sv-bootstrap-dropdown';
  let triggerEl = $state(null);
</script>

<Dropdown triggerElement={triggerEl}>
  <button
    type="button"
    class="btn btn-secondary dropdown-toggle"
    bind:this={triggerEl}
  >
    Dropdown
  </button>
  {#snippet dropdownMenu()}
    <a class="dropdown-item" href="#">Action</a>
    <a class="dropdown-item" href="#">Another action</a>
    <a class="dropdown-item" href="#">Something else here</a>
  {/snippet}
</Dropdown>

Split button

<script>
  import Dropdown from 'sv-bootstrap-dropdown';
  let splitTrigger = $state(null);
</script>

<Dropdown triggerElement={splitTrigger} classes="btn-group">
  <button type="button" class="btn btn-danger">Danger</button>
  <button
    type="button"
    class="btn btn-danger dropdown-toggle dropdown-toggle-split"
    bind:this={splitTrigger}
  >
    <span class="visually-hidden">Toggle Dropdown</span>
  </button>
  {#snippet dropdownMenu()}
    <a class="dropdown-item" href="#">Action</a>
    <a class="dropdown-item" href="#">Another action</a>
    <hr class="dropdown-divider" />
    <a class="dropdown-item" href="#">Something else here</a>
  {/snippet}
</Dropdown>

Placement

<Dropdown placement="top-end" triggerElement={triggerEl}>...</Dropdown>

Manual control

Use bind:open to control the dropdown programmatically.

<script>
  let open = $state(false);
  let triggerEl = $state(null);
</script>

<Dropdown triggerElement={triggerEl} bind:open>
  <span bind:this={triggerEl}>Target</span>
  {#snippet dropdownMenu()}
    <a class="dropdown-item" href="#">Action</a>
  {/snippet}
</Dropdown>
<button onclick={() => (open = !open)}>Toggle</button>

Migrating from Svelte 3

The named slot="DropdownMenu" is replaced by a {#snippet dropdownMenu()} prop:

<!-- Svelte 3 (old) -->
<div slot="DropdownMenu">
  <a class="dropdown-item" href="#">Item</a>
</div>

<!-- Svelte 5 (new) -->
{#snippet dropdownMenu()}
  <a class="dropdown-item" href="#">Item</a>
{/snippet}

Bootstrap 5 also renames droprightdropend and dropleftdropstart, which the component handles automatically.

Props

| Name | Type | Default | Description | | --------------------- | ------------------ | ---------------- | ------------------------------------------------------------------------------------------------- | | open | boolean | false | Controls visibility. Supports bind:open. | | triggerElement | HTMLElement | null | Popper anchor element (also the click toggle when autoToggle is true). | | autoToggle | boolean | true | Attach click-toggle to triggerElement. Set to false for fully manual control via bind:open. | | flip | boolean | true | Allow Popper to flip when there is not enough space. | | placement | string | 'bottom-start' | Popper placement. Accepts any Popper placement string. | | displayStatic | boolean | false | Disable dynamic Popper positioning. | | keyboard | boolean | true | Close on Escape; navigate with Arrow keys. | | insideClick | boolean | false | Keep open when clicking inside the menu. | | closeOnOutsideClick | boolean | true | Close when clicking outside. | | offset | [number, number] | [0, 2] | [skidding, distance] offset from the trigger. | | menuClasses | string | '' | Extra classes for .dropdown-menu. | | classes | string | '' | Extra classes for the wrapper element. | | labelledby | string | '' | aria-labelledby for .dropdown-menu. | | onOpened | () => void | () => {} | Callback when the dropdown opens. | | onClosed | () => void | () => {} | Callback when the dropdown closes. | | children | Snippet | — | Default slot (typically the trigger button). | | dropdownMenu | Snippet | — | Menu items snippet. |

License

Apache-2.0