Sidebar
Description
A sidebar navigation component
A fully featured Sidebar with Search, Navigation, Buttons, and Separators.
API reference
public sealed class Sidebar : IComponentA Sidebar component that can be collapsed or expanded, containing header, middle, and footer sections.
Constructors
Properties
Methods
public Sidebar Secondary()Sets the sidebar background to the secondary background color.
Returns
The current instance of the type.
public void Sortable(bool sortable = true)Sets whether the middle content items are sortable.
Parameters
- sortable
- Whether items are sortable.
public Sidebar Closed(bool isClosed = true)Sets whether the sidebar is closed.
Parameters
- isClosed
- Whether the sidebar is closed.
Returns
The current instance of the type.
public Sidebar Toggle()Toggles the closed state of the sidebar.
Returns
The current instance of the type.
public Sidebar AddHeader(ISidebarItem item)Adds an item to the sidebar header section.
Parameters
- item
- The item to add.
Returns
The current instance of the type.
public Sidebar InsertAfterHeader(ISidebarItem item, ISidebarItem addAfter)Inserts an item after another item in the sidebar header section.
Parameters
- item
- The item to insert.
- addAfter
- The item to insert after.
Returns
The current instance of the type.
public Sidebar AddContent(ISidebarItem item)Adds an item to the middle content section.
Parameters
- item
- The item to add.
Returns
The current instance of the type.
public Sidebar InsertAfterContent(ISidebarItem item, ISidebarItem addAfter)Inserts an item after another item in the middle content section.
Parameters
- item
- The item to insert.
- addAfter
- The item to insert after.
Returns
The current instance of the type.
public Sidebar RemoveContent(ISidebarItem item)Removes an item from the middle content section.
Parameters
- item
- The item to remove.
Returns
The current instance of the type.
public void LoadSorting(Dictionary<string, string[]> itemOrder)Loads the sorting order for sidebar items. Should be called after all items have been added.
Parameters
- itemOrder
- A dictionary mapping group identifiers to ordered item identifiers.
public Dictionary<string, string[]> GetCurrentSorting()Gets the current sorting order of all items in the sidebar.
Returns
A dictionary mapping group identifiers to ordered item identifiers.
public void OnSortingChanged(Action<Dictionary<string, string[]>> onSortingChanged)Adds a sorting change event handler.
Parameters
- onSortingChanged
- The event handler.
public void Search(string searchTerm)Searches/Filters the sidebar content items.
Parameters
- searchTerm
- The term to search for.
Fields
public const int SIDEBAR_TRANSITION_TIME = 300The transition time for sidebar animations in milliseconds.
public const string ROOT_SIDEBAR_FOR_ORDERING = "ROOT"The root identifier used for ordering.
public class SidebarButton : ISearchableSidebarItemA Button component for use within a Sidebar, supporting both open and closed states.
Properties
public bool IsSelected { get ; set ; }Gets or sets whether the button is currently selected.
public IComponent CurrentRenderedGets the component that is currently rendered.
public string Identifier { get; private set; }Gets the full identifier of the button.
Methods
public void AddGroupIdentifier(string groupIdentifier)Adds a group identifier prefix to the button's identifier.
public SidebarButton NotSortable()Marks the button as not sortable.
Returns
The current instance of the type.
public SidebarButton ClearProgress()Clears the progress indication background.
Returns
The current instance of the type.
public SidebarButton Progress(float progress)Sets a progress indication background.
Parameters
- progress
- The progress value (0 to 1).
Returns
The current instance of the type.
public SidebarButton SetText(string text)Sets the text of the button.
Parameters
- text
- The text.
Returns
The current instance of the type.
public SidebarButton CommandsAlwaysVisible(bool alwaysVisible = true)Ensures that commands associated with the button are always visible when the sidebar is open.
Returns
The current instance of the type.
public SidebarButton Light()Sets the button to use a light style.
Returns
The current instance of the type.
public SidebarButton Danger()Sets the button to use a danger style.
Returns
The current instance of the type.
public SidebarButton Default()Sets the button to use the default style.
Returns
The current instance of the type.
public SidebarButton Success()Sets the button to use a success style.
Returns
The current instance of the type.
public SidebarButton Primary()Sets the button to use the primary style.
Returns
The current instance of the type.
public SidebarButton Selected(bool isSelected = true)Sets whether the button is selected.
Parameters
- isSelected
- Whether the button is selected.
Returns
The current instance of the type.
public SidebarButton Tooltip(string text)Sets a tooltip for the closed state button.
Parameters
- text
- The tooltip text.
Returns
The current instance of the type.
public SidebarButton Tooltip(IComponent tooltip)Sets a tooltip component for the closed state button.
Parameters
- tooltip
- The tooltip component.
Returns
The current instance of the type.
public SidebarButton Tooltip(Func<IComponent> tooltip)Sets a tooltip generator function for the closed state button.
Parameters
- tooltip
- The tooltip generator function.
Returns
The current instance of the type.
public SidebarButton OpenedTooltip(string text)Sets a tooltip for the open state button.
Parameters
- text
- The tooltip text.
Returns
The current instance of the type.
public SidebarButton OpenedTooltip(IComponent tooltip)Sets a tooltip component for the open state button.
Parameters
- tooltip
- The tooltip component.
Returns
The current instance of the type.
public SidebarButton OpenedTooltip(Func<IComponent> tooltip)Sets a tooltip generator function for the open state button.
Parameters
- tooltip
- The tooltip generator function.
Returns
The current instance of the type.
public SidebarButton OnClick(Action action)Adds a click event handler to the button.
Parameters
- action
- The event handler action.
Returns
The current instance of the type.
public SidebarButton OnOpenIconClick(Action<HTMLElement, MouseEvent> action)Adds a click event handler to the icon when the button is open.
Parameters
- action
- The event handler action.
Returns
The current instance of the type.
public SidebarButton Id(string id)Sets the ID of the button.
Parameters
- id
- The ID.
Returns
The current instance of the type.
public SidebarButton OnOpenIconClick(Action action)Adds a click event handler to the icon when the button is open.
Parameters
- action
- The event handler action.
Returns
The current instance of the type.
public SidebarButton OnContextMenu(Action action)Adds a context menu event handler to the button.
Parameters
- action
- The event handler action.
Returns
The current instance of the type.
public SidebarButton OnClick(Action<Button, MouseEvent> action)Adds a click event handler with button and mouse event arguments.
Parameters
- action
- The event handler action.
Returns
The current instance of the type.
public SidebarButton OnContextMenu(Action<Button, MouseEvent> action)Adds a context menu event handler with button and mouse event arguments.
Parameters
- action
- The event handler action.
Returns
The current instance of the type.
public SidebarButton SetIcon(UIcons icon, string color = "", UIconsWeight weight = UIconsWeight.Regular)Sets the icon for the button.
Parameters
- icon
- The icon.
- color
- The color of the icon.
- weight
- The weight of the icon.
Returns
The current instance of the type.
public SidebarButton SetIcon(Emoji icon)Sets an emoji icon for the button.
Parameters
- icon
- The emoji icon.
Returns
The current instance of the type.
public ISidebarItem OnRendered(Action<HTMLElement> onRendered)Adds a rendered event handler.
Parameters
- onRendered
- The rendered event handler.
Returns
The current instance of the type.
public IComponent RenderClosed()Renders the button for the closed state of the sidebar.
public class SidebarCommand : IComponentA Command component for use within a Sidebar, typically appearing as a small action button.
Methods
public SidebarCommand Foreground(string color)Sets the foreground color of the command button.
Parameters
- color
- The color.
Returns
The current instance of the type.
public SidebarCommand HookToParentContextMenu()Configures the command to hook into the parent's context menu event.
Returns
The current instance of the type.
public SidebarCommand Background(string color)Sets the background color of the command button.
Parameters
- color
- The color.
Returns
The current instance of the type.
public SidebarCommand Default()Sets the command to use the default style.
Returns
The current instance of the type.
public SidebarCommand Primary()Sets the command to use the primary style.
Returns
The current instance of the type.
public SidebarCommand Success()Sets the command to use the success style.
Returns
The current instance of the type.
public SidebarCommand Danger()Sets the command to use the danger style.
Returns
The current instance of the type.
public SidebarCommand Tooltip(string text)Sets a tooltip for the command.
Parameters
- text
- The tooltip text.
Returns
The current instance of the type.
public SidebarCommand Tooltip(IComponent tooltip)Sets a tooltip component for the command.
Parameters
- tooltip
- The tooltip component.
Returns
The current instance of the type.
public SidebarCommand Tooltip(Func<IComponent> tooltip)Sets a tooltip generator function for the command.
Parameters
- tooltip
- The tooltip generator function.
Returns
The current instance of the type.
public SidebarCommand OnClickMenu(Func<ISidebarItem[]> generator)Configures the command to show a menu when clicked.
Parameters
- generator
- A function that generates the sidebar items for the menu.
Returns
The current instance of the type.
public SidebarCommand RaiseOnClick(MouseEvent mouseEvent)Programmatically raises the click event.
Parameters
- mouseEvent
- The mouse event arguments.
Returns
The current instance of the type.
public SidebarCommand RaiseOnContextMenu(MouseEvent mouseEvent)Programmatically raises the context menu event.
Parameters
- mouseEvent
- The mouse event arguments.
Returns
The current instance of the type.
public SidebarCommand OnClick(Action action)Adds a click event handler.
Parameters
- action
- The event handler action.
Returns
The current instance of the type.
public SidebarCommand OnContextMenu(Action action)Adds a context menu event handler.
Parameters
- action
- The event handler action.
Returns
The current instance of the type.
public SidebarCommand OnClick(Action<Button, MouseEvent> action)Adds a click event handler with button and mouse event arguments.
Parameters
- action
- The event handler action.
Returns
The current instance of the type.
public SidebarCommand OnContextMenu(Action<Button, MouseEvent> action)Adds a context menu event handler with button and mouse event arguments.
Parameters
- action
- The event handler action.
Returns
The current instance of the type.
public SidebarCommand SetIcon(UIcons icon, string color = "", UIconsWeight weight = UIconsWeight.Regular)Sets the icon for the command.
Parameters
- icon
- The icon.
- color
- The color of the icon.
- weight
- The weight of the icon.
Returns
The current instance of the type.
public SidebarCommand SetIcon(Emoji icon)Sets an emoji icon for the command.
Parameters
- icon
- The emoji icon.
Returns
The current instance of the type.
public class SidebarCommands : ISidebarItemA component for grouping multiple SidebarCommand items into a single line within a Sidebar.
Properties
public bool IsSelected { get; set; }Gets or sets whether the group is currently selected.
public IComponent CurrentRendered { get; private set; }Gets the component that is currently rendered.
public string Identifier { get; private set; }Gets the full identifier of the command group.
Methods
public IComponent RenderOpen()Renders the commands for the open state of the sidebar.
public IComponent RenderOpenFull()Renders all commands for the open state without truncation.
public IComponent RenderClosed()Renders the commands for the closed state of the sidebar.
public SidebarCommands AlignEnd()Aligns the commands to the end of the line.
Returns
The current instance of the type.
public SidebarCommands NotSortable()Marks the commands as not sortable.
Returns
The current instance of the type.
public class SidebarText : ISidebarItemA Text component for use within a Sidebar, supporting both open and closed states.
Constructors
public SidebarText(string identifier, string text, string closedText = null, TextSize textSize = TextSize.Small, TextWeight textWeight = TextWeight.Regular)Initializes a new instance of the SidebarText class.
Parameters
- identifier
- The identifier for the text item.
- text
- The text to display when the sidebar is open.
- closedText
- The optional text to display when the sidebar is closed.
- textSize
- The size of the text.
- textWeight
- The weight of the text.
Properties
public IComponent CurrentRenderedGets the component that is currently rendered.
public bool IsSelected { get; set; }Gets or sets whether the item is currently selected.
public string Identifier { get; private set; }Gets the full identifier of the text component.
Methods
public SidebarText NotSortable()Marks the text component as not sortable.
Returns
The current instance of the type.
public void AddGroupIdentifier(string groupIdentifier)Adds a group identifier prefix to the text component's identifier.
public SidebarText SetText(string text)Sets the text content for the open state.
Parameters
- text
- The text.
Returns
The current instance of the type.
public SidebarText Foreground(string color)Sets the foreground color of the text.
Parameters
- color
- The color.
Returns
The current instance of the type.
public SidebarText PT(int pixels)Sets the top padding of the text.
Parameters
- pixels
- The padding in pixels.
Returns
The current instance of the type.
public SidebarText PB(int pixels)Sets the bottom padding of the text.
Parameters
- pixels
- The padding in pixels.
Returns
The current instance of the type.
public SidebarText PL(int pixels)Sets the left padding of the text.
Parameters
- pixels
- The padding in pixels.
Returns
The current instance of the type.
public IComponent RenderClosed()Renders the text for the closed state of the sidebar.
public class SidebarBadge : IComponentA Badge component for sidebar items, often used to display counts or status indicators.
Constructors
public SidebarBadge(string badge, UIcons badgeIcon, TextSize iconSize = TextSize.Tiny)Initializes a new instance of the SidebarBadge class.
Parameters
- badge
- The text content of the badge.
- badgeIcon
- An optional icon for the badge.
- iconSize
- The size of the icon.
public SidebarBadge(string badge, UIcons badgeIcon)Initializes a new instance of the SidebarBadge class.
Parameters
- badge
- The text content of the badge.
- badgeIcon
- An optional icon for the badge.
public SidebarBadge(string badge)Initializes a new instance of the SidebarBadge class.
Parameters
- badge
- The text content of the badge.
Methods
public SidebarBadge SemiTransparent()Sets the badge icon to be semi-transparent.
Returns
The current instance of the type.
public SidebarBadge Foreground(string color)Sets the foreground color of the badge.
Parameters
- color
- The color.
Returns
The current instance of the type.
public SidebarBadge Background(string color)Sets the background color of the badge.
Parameters
- color
- The color.
Returns
The current instance of the type.
public SidebarBadge Default()Sets the badge to use the default style.
Returns
The current instance of the type.
public SidebarBadge Primary()Sets the badge to use the primary style.
Returns
The current instance of the type.
public SidebarBadge Success()Sets the badge to use the success style.
Returns
The current instance of the type.
public SidebarBadge Danger()Sets the badge to use the danger style.
Returns
The current instance of the type.
public SidebarBadge Tooltip(string text)Sets a tooltip for the badge.
Parameters
- text
- The tooltip text.
Returns
The current instance of the type.
public SidebarBadge Tooltip(IComponent tooltip)Sets a tooltip component for the badge.
Parameters
- tooltip
- The tooltip component.
Returns
The current instance of the type.
public SidebarBadge Tooltip(Func<IComponent> tooltip)Sets a tooltip generator function for the badge.
Parameters
- tooltip
- The tooltip generator function.
Returns
The current instance of the type.
public SidebarBadge SetIcon(UIcons icon, string color = "", UIconsWeight weight = UIconsWeight.Regular)Sets the icon for the badge.
Parameters
- icon
- The icon.
- color
- The color of the icon.
- weight
- The weight of the icon.
Returns
The current instance of the type.
public SidebarBadge SetIcon(Emoji icon)Sets an emoji icon for the badge.
Parameters
- icon
- The emoji icon.
Returns
The current instance of the type.
public SidebarBadge SetBadge(string badge)Sets the text content of the badge.
Parameters
- badge
- The badge text.
Returns
The current instance of the type.