A library of UI tools that help you build totally-custom and accessible accordions, dialogs, modals, tooltips, and more with Svelte. Written exclusively in Typescript with extensive documentation and references.
<script lang="ts">
let [dialog$, dialog] = useDisclosure();
</script>
<dialog open use:dialog1.content="{$dialog$}">here is some content!</dialog>
<button use:dialog1.button="{$dialog$}" on:click="{dialog.toggle}">
click to open modal
</button>
Add it to your Svelte / Svelte Kit project:
npm install git+https://github.com/syfrtech/svelte-grip.git
Note: (alpha/beta releases may have breaking changes without warning)
let [tooltip$, tooltip] = useTooltip();
<span use:tooltip.trigger="{$tooltip$}">hover for info</span>
span
above, would register the events to track mouseover and focus to toggle the tooltip content.Note: reactive values have a $
suffix to indicate their reactiveness (ex: dialog1$
). You can subscribe to them with the $
prefix, so they end up looking like $dialog1$
It's actually quite easy! Although may a11y patterns do not account for transition animations, we can add this behavior with Svelte. For example:
{#if $dialog1$.isOpen}
<dialog
transition:fade="{{delay: 250, duration: 300}}"
open
use:dialog1.content="{$dialog1$}"
>
here is some content!
</dialog>
{/if}
The nice thing here is that svelte-grip does not interfere with Svelte. You can customize styling and animation transitions however you like using native Svelte syntax... which boils down to native HTML + JS 🤩!
Grip on car tires helps cars climb mountains of sand and mud. Grip on UI lets developers build apps quickly and funly🍻. This is possible with just a few simple rules for Grip:
This allows you to get the functionality you want without being constrained to a particular design style. This library can be used with any design framework:
It can be tempting to create wrapper functionality (like React), but we resist the temptation! Instead, the use:actions
to provide tool access without .svelte files. From there, you are welcome to extend your elements as Svelte components or additional actions as you see fit.
This library is intended to fulfill accessibility / a11y with documentation and references, but without the headache. Even if you think you don't want/need accessibility, you still probably want it. For example:
class="modal" id="modal1"
vs class="modal1"
)See also: