Skip to content

SusChoiceDialog

SusChoiceDialog

N-button choice card for modal dialogs — buttons render in order, awaitable ShowAsync resolves to the chosen index (or -1 on dismiss).

Package

SusKit · Molecules (commercial)

Open in Playground

SusKit · Molecules

Props

NameTypeDefault
TitleProp<string>"Choose"
MessageProp<string>""v-model
ButtonsProp<string[]>Array.Empty<string>()
ButtonIdsProp<string[]>Array.Empty<string>()

Slots

No slots.

Events

NameFieldPayload
ChooseOnChooseint
ChooseIdOnChooseIdstring

Style hooks

USS class contract — override appearance without touching C#. States toggle via these classes:

  • sus-choice-dialog
  • sus-choice-dialog__btn
  • sus-choice-dialog__buttons

Usage

xml
<template>
  <sus:SusChoiceDialog Title="Delete item?"
                       Message="This cannot be undone."
                       :Buttons="Options.Value"
                       @choose="OnChoose" />
</template>

<script>
public Prop<string[]> Options = new(new[] { "Cancel", "Delete" });
void OnChoose(int index) { /* index == Options.Value.Length - 1 → confirmed */ }
</script>
csharp
// Awaitable helper — hosts the card inside a SusModal and resolves when it closes.
int index = await SusChoiceDialog.ShowAsync(
    "Delete item?", "This cannot be undone.", "Cancel", "Delete");
if (index == 1) { /* confirmed */ }

Notes

  • The last entry in Buttons renders as the primary action (elevated / primary color); every other entry renders outlined / secondary — put the confirming choice last.
  • OnChoose(int) fires with the clicked index. ButtonIds is an optional array parallel to Buttons — when the clicked button has a matching id, OnChooseId(string) fires alongside it, so callers can key off a stable id instead of a position.
  • The static ShowAsync helper wraps the card in a SusModal host via SusModalService and resolves to -1 when the dialog is dismissed through the modal scrim without a button click.