<PrimerButton Size="ButtonSize.Small" @onclick="ToggleDialog">Open Basic Dialog</PrimerButton>
<PrimerDialog Title="Delete Confirmation"
SubTitle="Are you sure you want to delete?"
DialogWidth="auto"
Animation="DialogAnimation.Fade"
DangerType="false"
ShowCloseButton="true"
IsBackdropClickToClose="false"
FocusTrap="true"
IsOpen="@isOpen"
OnClose="@CloseDialog"
FooterButtons="@dialogButtons">
This is a basic dialog content.
</PrimerDialog>
<PrimerButton Size="ButtonSize.Small" @onclick="OpenSideDialog">Open Side Dialog</PrimerButton>
<PrimerSideDialog IsOpen="@isSideOpen"
Title="Settings Panel"
Style="width:500px"
Position="right"
OnClose="@(() => isSideOpen = false)">
<p>This is a side dialog content.</p>
</PrimerSideDialog>
<PrimerButton Size="ButtonSize.Small" @onclick="OpenDraggableDialog">Open Draggable Dialog</PrimerButton>
<PrimerDraggableDialog IsOpen="@isDragOpen"
Title="Draggable Dialog"
OnClose="@(() => isDragOpen = false)">
<p>This dialog can be moved freely.</p>
</PrimerDraggableDialog>
Available options for Dialog component
Name | Description | Default Value | CSS Class |
---|---|---|---|
IsOpen | Whether the dialog is open | false | - |
Title | Dialog title text | "Dialog" | - |
SubTitle | Dialog subtitle text | null | - |
DangerType | Show danger styling | false | border-danger |
ShowCloseButton | Show close button | true | - |
IsBackdropClickToClose | Backdrop click to close | true | - |
FocusTrap | Trap focus inside dialog | false | - |
FooterButtons | Footer button list | empty | - |
Available options for SideDialog component
Name | Description | Default Value | CSS Class |
---|---|---|---|
IsOpen | Whether the side dialog is open | false | - |
Title | Side dialog title | "Side Dialog" | - |
TitleContent | Additional header content | null | - |
Position | Position of side dialog | "right" | right, left |
Style | Custom width or styles | "400px" | - |
Available options for DraggableDialog component
Name | Description | Default Value | CSS Class |
---|---|---|---|
IsOpen | Whether the draggable dialog is open | false | - |
Title | Dialog title text | "Draggable Dialog" | - |
private bool isOpen = false;
private bool isSideOpen = false;
private bool isDragOpen = false;
private List<PrimerDialog.DialogButton> dialogButtons = new();
protected override void OnInitialized()
{
dialogButtons = new List<PrimerDialog.DialogButton>
{
new PrimerDialog.DialogButton { ButtonType = "default", Content = "Cancel", OnClick = CloseDialog },
new PrimerDialog.DialogButton { ButtonType = "danger", Content = "Delete", OnClick = DeleteItem },
new PrimerDialog.DialogButton { ButtonType = "primary", Content = "Continue", OnClick = ContinueAction }
};
}
private void ToggleDialog() => isOpen = !isOpen;
private void CloseDialog() => isOpen = false;
private void OpenSideDialog() => isSideOpen = true;
private void OpenDraggableDialog() => isDragOpen = true;
private void DeleteItem() { }
private async void ContinueAction()
{
await JSRuntime.InvokeVoidAsync("alert", "Continuing...");
CloseDialog();
}