Path: redb/redb.PropsEditor/Components/ArrayEditor.razor
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.PropsEditor/Components/ArrayEditor.razor
----
@using Microsoft.FluentUI.AspNetCore.Components
@* Editor for string arrays with add/remove functionality *@
@for (int i = 0; i < Items.Length; i++)
{
var index = i;
[@index]
@if (!IsReadOnly)
{
X
}
}
@if (Items.Length == 0)
{
No items. Click "Add" to add one.
}
@code {
[Parameter]
public string[] Items { get; set; } = [];
[Parameter]
public EventCallback OnItemsChanged { get; set; }
[Parameter]
public bool IsReadOnly { get; set; }
private async Task AddItem()
{
var newItems = Items.Append("").ToArray();
await OnItemsChanged.InvokeAsync(newItems);
}
private async Task RemoveItem(int index)
{
var newItems = Items.Where((_, i) => i != index).ToArray();
await OnItemsChanged.InvokeAsync(newItems);
}
private async Task UpdateItem(int index, string value)
{
var newItems = Items.ToArray();
newItems[index] = value;
await OnItemsChanged.InvokeAsync(newItems);
}
}