# SbAddButton A specialized button for adding new items in builder interfaces. Supports a dropdown menu of options or direct add action. Perfect for visual builders and content editors. ## Parameters | Parameter | Type | Default | Description | |-----------|------|---------|-------------| | Label | string? | null | Button label text | | Options | List | [] | Dropdown options for different add types | | Variant | SbAddButtonVariant | Default | Button variant (Default, Primary, Outline, Ghost) | | Size | SbAddButtonSize | Medium | Button size (Small, Medium, Large) | | Disabled | bool | false | Whether the button is disabled | | AriaLabel | string | "Add item" | Accessibility label | | Class | string? | null | Additional CSS classes | ## Events | Event | Type | Description | |-------|------|-------------| | OnOptionSelected | EventCallback | Fired when a dropdown option is selected | | OnAdd | EventCallback | Fired on click when no options are provided | ## Templates / Slots | Slot | Type | Description | |------|------|-------------| | Icon | RenderFragment? | Custom icon content (replaces default + icon) | ## SbAddOption Class | Property | Type | Description | |----------|------|-------------| | Id | string | Unique identifier | | Label | string | Display label | | Description | string? | Optional description text | | IconText | string? | Icon text (emoji or symbol) | | Icon | RenderFragment? | Custom icon content | | Disabled | bool | Whether the option is disabled | | Data | object? | Custom data associated with option | ## CSS Classes - `sb-add-button-container` - Container wrapper - `sb-add-button` - Button element - `sb-add-button--active` - Menu is open - `sb-add-button__icon` - Icon container - `sb-add-button__icon--rotated` - Rotated when open - `sb-add-button__label` - Label text - `sb-add-button__menu` - Dropdown menu - `sb-add-button__option` - Menu option - `sb-add-button__option-icon` - Option icon - `sb-add-button__option-label` - Option label - `sb-add-button__option-description` - Option description ## Examples ### Simple Add Button ```razor @code { private void HandleAdd() { // Add new item } } ``` ### With Dropdown Options ```razor @code { private List blockOptions = new() { new() { Id = "text", Label = "Text Block", IconText = "πŸ“", Description = "Add a paragraph" }, new() { Id = "image", Label = "Image", IconText = "πŸ–ΌοΈ", Description = "Add an image" }, new() { Id = "video", Label = "Video", IconText = "🎬", Description = "Embed a video" }, new() { Id = "divider", Label = "Divider", IconText = "β€”", Description = "Add a separator" } }; private void HandleOptionSelected(SbAddOption option) { Console.WriteLine($"Selected: {option.Id}"); } } ``` ### Variants ```razor ``` ### Sizes ```razor ``` ### Custom Icon ```razor ``` ### Icon Only ```razor ``` ### Page Builder Example ```razor
@foreach (var block in blocks) {
@block.Content
}
@code { private List blocks = new(); private List contentOptions = new() { new() { Id = "heading", Label = "Heading", IconText = "H", Description = "Add a heading" }, new() { Id = "paragraph", Label = "Paragraph", IconText = "ΒΆ", Description = "Add text content" }, new() { Id = "list", Label = "List", IconText = "β€’", Description = "Add a bulleted list" }, new() { Id = "quote", Label = "Quote", IconText = "❝", Description = "Add a blockquote" }, new() { Id = "code", Label = "Code", IconText = "", Description = "Add a code block" } }; private void AddBlock(SbAddOption option) { blocks.Add(new Block { Type = option.Id, Content = $"New {option.Label}" }); } } ```