A headless dialog close component that provides necessary accessibility and state properties to a button or custom element to close a dialog.
<!--
Source: https://github.com/huntabyte/bits-ui | License: MIT | Copyright 2024 Hunter Johnston <https://github.com/huntabyte>
Provided via justclaw.it.com; keep this notice with the code.
-->
<script lang="ts">
import { boxWith, mergeProps } from "svelte-toolbelt";
import { DialogCloseState } from "../dialog.svelte.js";
import type { DialogCloseProps } from "../types.js";
import { createId } from "#lib/internal/create-id.js";
const uid = $props.id();
let {
children,
child,
id = createId(uid),
ref = $bindable(null),
disabled = false,
...restProps
}: DialogCloseProps = $props();
const closeState = DialogCloseState.create({
variant: boxWith(() => "close"),
id: boxWith(() => id),
ref: boxWith(
() => ref,
(v) => (ref = v)
),
disabled: boxWith(() =>
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key