enes

Dialog

A dialog is a window overlaid on either the primary window or another dialog window.

Dialog Title

Lorem ipsum dolor sit amet consectetur adipisicing elit. Quisquam, voluptates.

The Dialog is composed of several components that work together through a shared context:

  • Dialog: The root component that creates the state and provides context to its children.
  • DialogTrigger: A button that opens the dialog when clicked.
  • DialogSurface: The `<dialog>` element that hosts the dialog content.
  • DialogTitle: The heading of the dialog. Renders as an `h3` by default.
  • DialogContent: The scrollable body of the dialog.
  • DialogActions: The footer that holds action buttons.

Usage

<script>
	import {
		Dialog,
		DialogTrigger,
		DialogSurface,
		DialogTitle,
		DialogContent,
		DialogActions,
		Button
	} from 'fluentui-svelte';

	let dialog = $state();
</script>

<Dialog bind:this={dialog}>
	<DialogTrigger>Open Dialog</DialogTrigger>
	<DialogSurface>
		<DialogTitle>Dialog Title</DialogTitle>
		<DialogContent>
			<p>Lorem ipsum dolor sit amet consectetur adipisicing elit.</p>
		</DialogContent>
		<DialogActions fluid>
			<Button>Save</Button>
			<Button appearance="standard" onclick={() => dialog.closeDialog()}>Close</Button>
		</DialogActions>
	</DialogSurface>
</Dialog>

With Actions

Add a DialogActions region to render action buttons in the dialog footer. Use bind:this on the Dialog to call closeDialog() programmatically.

Dialog Title

Dialog body content.

Dialog Props

NameTypeDefaultDescription
type'modal' | 'non-modal' | 'alert''modal'How the dialog behaves once open.
open bindablebooleanControls the open state of the dialog.
onOpenChange(open: boolean) => voidCalled whenever the dialog opens or closes.
childrenSnippetThe parts of the dialog: a trigger and a surface.

DialogTrigger Props

NameTypeDefaultDescription
refHTMLButtonElementThe DOM reference of the trigger element.
ButtonProps<'button'>

DialogSurface Props

NameTypeDefaultDescription
ref bindableHTMLDialogElementThe DOM reference of the dialog element.
Element Attributes (dialog)

DialogTitle Props

NameTypeDefaultDescription
ref bindableHTMLDivElement | HTMLHeadingElementThe DOM reference of the title element.
asDialogTitleTag'h3'The HTML element to render the title as.
HTML Attributes

DialogContent Props

NameTypeDefaultDescription
refHTMLDivElementThe DOM reference of the content element.
Element Attributes (div)

DialogActions Props

NameTypeDefaultDescription
ref bindableHTMLDivElementThe DOM reference of the actions element.
fluidbooleanStretches every action to share the available width evenly.
position'start' | 'center' | 'end''end'Where the actions sit along the main axis.
Element Attributes (div)