Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/DevToys-app/DevToys/llms.txt

Use this file to discover all available pages before exploring further.

Interactive controls let the user drive the behaviour of a tool. DevToys provides buttons (plain, accent, hyperlink, and drop-down), a boolean toggle switch, a single-selection dropdown list, and a file-picker drop zone. For structured option UIs there is also the Setting and SettingGroup pattern, which renders a labeled setting row with any control as its interactive value.

Button

IUIButton is a clickable element that triggers a Func<ValueTask> when pressed. Buttons support three visual styles: neutral (default), accent, and hyperlink. A button can also carry an icon glyph from a named font.

Key properties

PropertyTypeDefaultDescription
Textstring?nullLabel shown inside the button.
IsAccentboolfalseRenders using the app’s accent colour.
IsHyperlinkboolfalseRenders as an inline hyperlink. Setting this also clears IsAccent.
IconFontNamestring?nullFont name for an optional icon glyph.
IconGlyphchar\0Glyph character within IconFontName.
OnClickActionFunc<ValueTask>?nullAction invoked on click.

Example

using static DevToys.Api.GUI;

IUIStack buttonRow =
    Stack()
        .Horizontal()
        .SmallSpacing()
        .WithChildren(
            Button()
                .Text("Convert")
                .AccentAppearance()
                .OnClick(OnConvertClicked),
            Button()
                .Text("Swap")
                .NeutralAppearance()
                .OnClick(OnSwapClicked),
            Button()
                .Text("Reset")
                .HyperlinkAppearance()
                .OnClick(OnResetClicked));

IUIDropDownButton is a button that opens a flyout menu of IUIDropDownMenuItem items. Use it when a single action concept has multiple variants (for example “Copy As JSON”, “Copy As XML”).

Key properties

PropertyTypeDefaultDescription
Textstring?nullLabel on the button face.
IconFontName / IconGlyphstring? / charnull / \0Optional icon glyph.
MenuItemsIUIDropDownMenuItem[]?nullThe items shown in the flyout.

IUIDropDownMenuItem properties

PropertyDescription
TextLabel of the menu item.
IsEnabledWhether the item is interactive. Default true.
IconFontName / IconGlyphOptional icon glyph.
OnClickActionFunc<ValueTask> invoked when the item is clicked.

Example

using static DevToys.Api.GUI;

IUIDropDownButton copyAsButton =
    DropDownButton()
        .Text("Copy As")
        .WithMenuItems(
            DropDownMenuItem("JSON")
                .OnClick(CopyAsJson),
            DropDownMenuItem("XML")
                .OnClick(CopyAsXml),
            DropDownMenuItem("YAML")
                .OnClick(CopyAsYaml),
            DropDownMenuItem("CSV")
                .OnClick(CopyAsCsv));

Switch

IUISwitch is a boolean toggle that emits an IsOn state change. It renders with configurable on/off labels (default: “On” / “Off”) and can be linked to a SettingDefinition<bool> via the Setting.Handle helper for automatic persistence.

Key properties

PropertyTypeDefaultDescription
IsOnboolfalseCurrent toggle state.
OnTextstring?"On"Label shown when the switch is on.
OffTextstring?"Off"Label shown when the switch is off.

Example

using static DevToys.Api.GUI;

private IUISwitch _indentSwitch =
    Switch("indent-toggle")
        .On()
        .OnText("Indented")
        .OffText("Minified")
        .OnToggle(OnIndentToggled);

private ValueTask OnIndentToggled(bool isOn)
{
    _outputEditor.Text(isOn ? _indentedOutput : _minifiedOutput);
    return ValueTask.CompletedTask;
}

SelectDropDownList

IUISelectDropDownList presents a dropdown list from which the user selects exactly one IUIDropDownListItem. Each item has a display Text and an associated Value (typed as object?).

Key properties

PropertyTypeDefaultDescription
ItemsIUIDropDownListItem[]?nullThe list of selectable items.
SelectedItemIUIDropDownListItem?nullCurrently selected item.
OnItemSelectedActionFunc<IUIDropDownListItem?, ValueTask>?nullCallback invoked when selection changes.

Creating list items

Use GUI.Item(text, value) to build each IUIDropDownListItem:
GUI.Item("UTF-8",  Encoding.UTF8)
GUI.Item("UTF-16", Encoding.Unicode)
GUI.Item("ASCII",  Encoding.ASCII)

Example

using static DevToys.Api.GUI;

private readonly IUISelectDropDownList _encodingSelector =
    SelectDropDownList("encoding")
        .Title("Output Encoding")
        .WithItems(
            Item("UTF-8",    Encoding.UTF8),
            Item("UTF-16",   Encoding.Unicode),
            Item("UTF-32",   Encoding.UTF32),
            Item("ASCII",    Encoding.ASCII))
        .Select(0)           // pre-select the first item (UTF-8)
        .OnItemSelected(OnEncodingSelected);

private ValueTask OnEncodingSelected(IUIDropDownListItem? item)
{
    if (item?.Value is Encoding encoding)
    {
        ApplyEncoding(encoding);
    }
    return ValueTask.CompletedTask;
}
Use .Select(index) to pre-select an item by its zero-based position in the list, or .Select(item) to select a specific IUIDropDownListItem instance.

FileSelector

IUIFileSelector combines a drop zone and a native file-picker button. The user can drag files, paste images from the clipboard, or browse for files. Selected files are exposed as SandboxedFileReader instances — a sandboxed wrapper that provides a Stream and a FileName without exposing the full filesystem path.

Key properties

PropertyTypeDefaultDescription
CanSelectManyFilesboolfalseAllow multiple files to be selected at once.
AllowedFileExtensionsstring[]empty (any)Restrict selectable files to these extensions (e.g. ".json", ".txt").
SelectedFilesSandboxedFileReader[]emptyThe currently selected files.
OnFilesSelectedActionFunc<SandboxedFileReader[], ValueTask>?nullCallback invoked when files are chosen.
SandboxedFileReader holds an open Stream. You are responsible for disposing each reader after use — DevToys does not dispose them automatically.

Example

using static DevToys.Api.GUI;

IUIFileSelector fileInput =
    FileSelector("file-drop")
        .CanSelectManyFiles()
        .LimitFileTypesTo(".json", ".jsonl", ".ndjson")
        .OnFilesSelected(OnFilesSelected);

private async ValueTask OnFilesSelected(SandboxedFileReader[] files)
{
    foreach (SandboxedFileReader file in files)
    {
        await using Stream stream = await file.GetNewAccessToFileContentAsync(CancellationToken.None);
        using var reader = new StreamReader(stream);
        string content = await reader.ReadToEndAsync();
        ProcessJsonContent(file.FileName, content);
        // SandboxedFileReader is disposed by the `await using` above
    }
}
To limit the selector to all built-in supported image formats, use the convenience method:
FileSelector("image-drop")
    .LimitFileTypesToImages()
    .CanSelectOneFile()
    .OnFilesSelected(OnImageSelected);

Setting

IUISetting renders a structured setting row with a Title, optional Description, optional StateDescription, an optional Icon, and an InteractiveElement (any IUIElement). It is the standard way to present tool or app options.

Key properties

PropertyTypeDescription
Titlestring?The setting name (via IUITitledElement).
Descriptionstring?Explanatory text beneath the title.
StateDescriptionstring?Dynamic text that reflects the current state (e.g. “Enabled”).
IconIUIIcon?Decorative icon beside the title.
InteractiveElementIUIElement?The control that changes the setting value.

Handle helpers

The .Handle(settingsProvider, settingDefinition, ...) overloads automatically wire up a Switch or SelectDropDownList to a persisted SettingDefinition — the binding is two-way:
// Boolean setting bound to a switch
Setting("indent-setting")
    .Title("Indent output")
    .Description("Produce human-readable, indented JSON output.")
    .Icon("FluentSystemIcons", '\uF6E6')
    .Handle(
        settingsProvider,
        IndentOutputSetting,
        stateDescriptionWhenOn: "On",
        stateDescriptionWhenOff: "Off",
        onToggled: OnIndentToggled);

SettingGroup

IUISettingGroup extends IUISetting with a Children array, allowing you to nest multiple IUISetting rows under a single group header:
using static DevToys.Api.GUI;

IUISettingGroup outputGroup =
    SettingGroup("output-settings")
        .Icon("FluentSystemIcons", '\uF4C9')
        .Title("Output")
        .Description("Configure how the converted data is formatted.")
        .WithSettings(
            Setting()
                .Title("Indent output")
                .Description("Add indentation and newlines to the generated output.")
                .InteractiveElement(
                    Switch().On().OnToggle(OnIndentToggled)),
            Setting()
                .Title("Sort keys")
                .Description("Sort object keys alphabetically.")
                .InteractiveElement(
                    Switch().Off().OnToggle(OnSortKeysToggled)),
            Setting()
                .Title("Output encoding")
                .InteractiveElement(
                    SelectDropDownList()
                        .WithItems(
                            Item("UTF-8",  "utf-8"),
                            Item("UTF-16", "utf-16"))
                        .Select(0)
                        .OnItemSelected(OnEncodingSelected)));

Build docs developers (and LLMs) love