diff --git a/components/button/disabled-button.md b/components/button/disabled-button.md new file mode 100644 index 0000000000..70fc9e5c51 --- /dev/null +++ b/components/button/disabled-button.md @@ -0,0 +1,35 @@ +--- +title: Disabled Button +page_title: Disabled Button +description: Learn how to configure a disabled Blazor Button component by Telerik UI. +slug: button-disabled +tags: telerik,blazor,disabled,button, +published: True +position: 5 +--- + +# Disabled Button + +Sometimes specific buttons in an application must be temporarily disabled. To control the enabled state of the component, use the `Enabled` Boolean attribute. + +The following example demonstrates how to enable and disable the Button. + +>caption Toggle Telerik Button Enabled State + +````CSHTML +

+ +

+ +@ButtonText + +@code { + bool ButtonIsEnabled { get; set; } = false; + string ButtonText => ButtonIsEnabled ? "Enabled Button" : "Disabled Button"; +} + +>caption Comparison between disabled and enabled button + +![](images/disabled-button.png) \ No newline at end of file diff --git a/components/button/overview.md b/components/button/overview.md index 63099e8874..7af906264f 100644 --- a/components/button/overview.md +++ b/components/button/overview.md @@ -1,7 +1,7 @@ --- title: Overview page_title: Button Overview -description: Overview of the Button for Blazor. +description: Discover the Blazor Button and explore the examples. slug: components/button/overview tags: telerik,blazor,button,overview published: True @@ -10,24 +10,19 @@ position: 0 # Button Overview -This article provides information about the Blazor Button component and its core features. +This article introduces the Blazor Button component, shows how to start using it, and lists its core features. -The Button component provides styling according to the [chosen theme]({%slug general-information/themes%}), click [event]({%slug button-events%}) and [icons]({%slug button-icons%}). You can also disable the button and set its [type]({%slug button-type%}). +Buttons convey user actions and can display text, images and HTML. -#### In this article: +The Blazor Button provides a variety of styling options through the [built-in themes]({%slug general-information/themes%}) and the [button type]({%slug button-type%}). It supports [font icons and images]({%slug button-icons%}) and fires click [events]({%slug button-events%}). -* [Basic Button](#basic-button) -* [Primary Button](#primary-button) -* [Disabled State](#disabled-state) -* [Styling](#styling) +## Creating Blazor Button +1. Use the `` tag to add the component to your razor page. +1. Add an `OnClick` event handler to show the current date and time. -## Basic Button - -To add a Telerik Button to your Blazor app, use the `` tag: - ->caption Basic Telerik Button with OnClick event handling +>caption Basic Blazor Button with OnClick event handler ````CSHTML @result @@ -44,95 +39,58 @@ To add a Telerik Button to your Blazor app, use the `` tag: } ```` ->caption The result from the code snippet above -![](images/basic-button.png) +## Icons ->caption Component namespace and reference +To visually communicate the purpose of a button, you can add an image, sprite, or font icon. You can choose between a wide range of built-in font icons or use your custom font icons. [Read more about the Blazor Button icons...]({%slug button-icons%}) -````CSHTML -@using Telerik.Blazor.Components +## Type -Hello! - -@code{ - Telerik.Blazor.Components.TelerikButton theButton; -} -```` +To control the submit behavior of the Blazor Button, use the `Type` attribute. Select from the following button types: `Submit`, `Reset`, and `Button`. [Read more about the Blazor Button Type...]({%slug button-type%}) -## Primary Button - -You can also make the button use a strong color to attact attention, called Primary button styling. To do that, set its `Primary` property to true. - ->caption Button with the Primary color scheme from the current theme - -````CSHTML -Primary -```` - ->caption The result from the code snippet above, with the Default theme - -![](images/primary-button.png) +## Events +The Blazor Button fires events that you can handle and respond to user actions. [Read more about the Blazor Button events...]({%slug button-events%}). ## Disabled State -To disable a button, set its `Enabled` attribute to `false`. - ->caption Disabled Telerik Button - -````CSHTML -Disabled Button -```` - ->caption Comparison between disabled and enabled button - -![](images/disabled-button.png) +To prevent user interaction with a Button, disable it. [Read more about the disabled Blazor Button...]({%slug button-disabled%}). ## Styling -You can style the button through its `Class` attribute to define your own CSS rules that apply to the HTML rendering. +To customize the style and the appearance of the Blazor Button, you can use the [built-in themes]({%slug general-information/themes%}). Additionally, set the `Class` attribute and implement custom CSS rules. [Read more about the Blazor Button styling...]({%slug button-styling%}) ->caption Set CSS class to the button and change its appearance +## Button Reference -````CSHTML -My text is red. - - -```` +Add a reference to the Button instance to use its methods (for example - `FocusAsync()`). ->caption The result from the code snippet above +>caption Component namespace and reference -![](images/red-button.png) +````CSHTML +Hello! +@code{ + Telerik.Blazor.Components.TelerikButton theButton { get; set; } ->caption Change the button size + protected override async Task OnAfterRenderAsync(bool firstRender) + { + await theButton.FocusAsync(); -```` - - -Large button +} ```` ->caption The result from the code snippet above +## Next Steps + +* [Styling the Blazor Button]({%slug button-styling%}) -![use css to change the button size](images/button-size-change.png) +* [Using Button Icons]({%slug button-icons%}) ## See Also * [Live Demo: Button](https://demos.telerik.com/blazor-ui/button/index) * [Events]({%slug button-events%}) - * [Icons]({%slug button-icons%}) * [Type]({%slug button-type%}) * [API Reference](https://docs.telerik.com/blazor-ui/api/Telerik.Blazor.Components.TelerikButton) - + diff --git a/components/button/styling.md b/components/button/styling.md new file mode 100644 index 0000000000..c05a34a971 --- /dev/null +++ b/components/button/styling.md @@ -0,0 +1,46 @@ +--- +title: Styling +page_title: Styling +description: Learn how to apply styles to the Blazor Button component by Telerik UI. +slug: button-styling +tags: telerik,blazor,button,styling, +published: True +position: 10 +--- + +# Styling + +There are a few ways to style the Button component: + +* Set a [primary button](#primary-button) style. +* Use another [built-in theme]({%slug general-information/themes%}). +* Use the [Button `Class`](#button-class) attribute. + +## Primary Button + +Through the primary button styling, you can make the button use a strong color to attract attention. To do that, set its `Primary` property to true. + +>caption Button with the Primary color scheme from the current theme + +````CSHTML +Primary +```` + +## Button Class + +The Class attribute allows you to define custom CSS rules that apply to the HTML rendering of one or several Buttons. + +>caption Set CSS class to the button and change its appearance + +````CSHTML +Large button with red text + + +```` diff --git a/components/contextmenu/events.md b/components/contextmenu/events.md index 043e6806df..38dbebc345 100644 --- a/components/contextmenu/events.md +++ b/components/contextmenu/events.md @@ -16,26 +16,27 @@ This article explains the events available in the Telerik Context Menu for Blazo ## OnClick -The `OnClick` event fires when the user clicks or taps on a menu item. It receives the model of the item as an argument that you can cast to the concrete model type you are using. +The `OnClick` event fires when the user clicks or taps on a menu item. The event handler receives an argument of type `ContextMenuClickEventArgs` with the item model (`args.Item`) and a boolean flag that controls component re-rendering (`args.ShouldRender`) after the event. -You can use the `OnClick` event to react to user choices in a menu without using navigation to load new content automatically. +You can use the `OnClick` event to react to user choices, for example load new content without using navigation. >caption Handle OnClick ````CSHTML -Last clicked item: @ClickedItem?.Text -
right click for context menu
+

Last clicked item: @ClickedItem?.Text

+ +
right-click for context menu
+ OnClick="@((ContextMenuClickEventArgs args) => OnClickHandler(args))"> @code { public MenuItem ClickedItem { get; set; } - protected void OnClickHandler(MenuItem item) + protected void OnClickHandler(ContextMenuClickEventArgs args) { - ClickedItem = item; + ClickedItem = args.Item; } public List MenuItems { get; set; } diff --git a/components/contextmenu/integration.md b/components/contextmenu/integration.md index 0a475e0b2c..28d2dcb561 100644 --- a/components/contextmenu/integration.md +++ b/components/contextmenu/integration.md @@ -43,7 +43,7 @@ Hooking to your own HTML elements' events lets you determine what to do with the + OnClick="@( (ContextMenuClickEventArgs args) => ContextMenuClickHandler(args) )"> @@ -79,8 +79,9 @@ Hooking to your own HTML elements' events lets you determine what to do with the MenuItems[2].Items[0].Disabled = clickedItem.IsSpecial; } - async Task ContextMenuClickHandler(ContextMenuItem clickedItem) + void ContextMenuClickHandler(ContextMenuClickEventArgs args) { + var clickedItem = args.Item; // handle the command from the context menu by using the stored metadata if (!string.IsNullOrEmpty(clickedItem.CommandName) && LastClickedItem != null) { @@ -92,9 +93,8 @@ Hooking to your own HTML elements' events lets you determine what to do with the // generate sample data for the listview and the menu protected override void OnInitialized() { - MenuItems = new List() - { + { new ContextMenuItem { Text = "More Info", @@ -185,7 +185,7 @@ In this example, the context menu is used to select/deselect items, put an item @using System.Collections.ObjectModel + OnClick="@((ContextMenuClickEventArgs args) => ContextMenuClickHandler(args))"> args) { + var item = args.Item; // one way to pass handlers is to use an Action, you don't have to use this if (item.Action != null) { @@ -403,7 +404,7 @@ In this example, the context menu is used to select/deselect items and delete it + OnClick="@((ContextMenuClickEventArgs args) => ContextMenuClickHandler(args))"> args) { - + var item = args.Item; // Use local code to perform a task such as put select/deselect a node or delete it switch (item.CommandName) { diff --git a/components/contextmenu/overview.md b/components/contextmenu/overview.md index ac5767d15c..8273ab8b70 100644 --- a/components/contextmenu/overview.md +++ b/components/contextmenu/overview.md @@ -32,15 +32,15 @@ In addition to built-in [navigation capabilities]({%slug contextmenu-navigation% + OnClick="@( (ContextMenuClickEventArgs args) => ClickHandler(args) )"> - @code { public List MenuItems { get; set; } - async Task ClickHandler(ContextMenuItem clickedItem) + async Task ClickHandler(ContextMenuClickEventArgs args) { + var clickedItem = args.Item; if (!string.IsNullOrEmpty(clickedItem.CommandName)) { Console.WriteLine($"The programm will now perform the {clickedItem.CommandName} operation"); diff --git a/components/drawer/data-bind.md b/components/drawer/data-bind.md index c495d7a365..c9a48897fa 100644 --- a/components/drawer/data-bind.md +++ b/components/drawer/data-bind.md @@ -66,9 +66,9 @@ https://docs.telerik.com/blazor-ui/components/drawer/navigation - + @Body - + @code { diff --git a/components/drawer/events.md b/components/drawer/events.md index 388dbc36a2..04c4be043b 100644 --- a/components/drawer/events.md +++ b/components/drawer/events.md @@ -28,11 +28,11 @@ The `SelectedItemChanged` event fires every time the user clicks on a new item f - +
Content for the @selectedItem?.Text
-
+
@code { @@ -91,11 +91,11 @@ The `ExpandedChanged` event fires every time the component's state is changed - Mode="@DrawerMode.Push" @bind-SelectedItem="@selectedItem" @ref="@DrawerRef"> - +
Content for the @selectedItem?.Text
-
+ @code { diff --git a/components/drawer/icons.md b/components/drawer/icons.md index c39b055eed..bfb61eff94 100644 --- a/components/drawer/icons.md +++ b/components/drawer/icons.md @@ -32,12 +32,12 @@ The `IconClassField` and `ImageUrlField` are rendered, respectively, as ` - + Toggle drawer
Selected Item: @SelectedItem?.Text
-
+ @code { diff --git a/components/drawer/modes.md b/components/drawer/modes.md index b13bbf5e74..78b3fc4d0e 100644 --- a/components/drawer/modes.md +++ b/components/drawer/modes.md @@ -43,14 +43,14 @@ The drawer's height is dynamic based on the height of the content (you can chang Mode="@DrawerMode.Push" @bind-SelectedItem="@selectedItem" @ref="@DrawerRef"> - +
Select an item. The drawer is expaned: @Expanded
Content for the @selectedItem?.Text
-
+ @@ -94,13 +94,13 @@ You may want to add padding to the left of the content so that it is not overlap Mode="@DrawerMode.Overlay" @bind-SelectedItem="@selectedItem" @ref="@DrawerRef"> - +
The drawer is expanded: @Expanded
Content for the @selectedItem?.Text
-
+ @code { diff --git a/components/drawer/navigation.md b/components/drawer/navigation.md index f2374e0fb4..2f7d4b02a5 100644 --- a/components/drawer/navigation.md +++ b/components/drawer/navigation.md @@ -15,7 +15,7 @@ The Drawer is a different kind of a [menu]({%slug components/menu/overview%}) th To use the Drawer for navigating between pages: * Add the Drawer to the `MainLayot.razor` of your app. -* Put the `@Body` tag in the `` tag of the drawer. +* Put the `@Body` tag in the `` tag of the drawer. * Provide a collection of models that describe the pages you want the user to navigate to. >tip You can find a runnable sample that showcases this in the [Drawer as Side Navigation](https://github.com/telerik/blazor-ui/tree/master/drawer/sidenav) sample project. @@ -31,9 +31,9 @@ To use the Drawer for navigating between pages: - + @Body - + diff --git a/components/drawer/overview.md b/components/drawer/overview.md index e743499f5a..120d7d29a5 100644 --- a/components/drawer/overview.md +++ b/components/drawer/overview.md @@ -16,7 +16,7 @@ The Blazor Dr 1. Add the `TelerikDrawer` tag. 1. Populate its `Data` property with the collection of items you want the user to see. -1. Place the content of the Drawer in the `` tag. +1. Place the content of the Drawer in the `` tag. * In this example, we keep it simple by using the selected item. See the [Navigation]({%slug drawer-navigation%}) article for a menu-like experience with links. >caption Basic configuration of the Drawer. @@ -29,7 +29,7 @@ The Blazor Dr Mode="DrawerMode.Push" @ref="@DrawerRef" @bind-SelectedItem="@SelectedItem"> - + Toggle drawer @* Place your contents here - it can be as simple as text, it can be conditional components or components that @@ -38,7 +38,7 @@ The Blazor Dr
Selected Item: @SelectedItem?.Text
-
+ @code { @@ -73,7 +73,7 @@ The Blazor Dr * `Position` - you can control the position of the Drawer, through the `DrawerPosition` enum. The members of the enum are: * `Left` - the default position - * `Right` - the drawer item list will render on the right hand side of the `Content` + * `Right` - the drawer item list will render on the right hand side of the `DrawerContent` * `Expanded` - two-way bindable property that specifies whether the Drawer is expanded or collapsed. If this parameter is used to expand or collapse the component the animations will not be available. To use animations you have to use the Drawer's [Methods](#methods). You can, however, use the value to implement custom layouts in the drawer [templates]({%slug drawer-templates%}) or in your own layout. @@ -85,7 +85,7 @@ The members of the enum are: * `MiniMode` - controls whether there is mini view when the Drawer is collapsed. For more information read the [Mini View]({%slug drawer-mini-mode%}) article. -* `Content` - the `` child tag of `` is a `RenderFragment` where you put a component or custom HTML as the content of the Drawer - this is what the drawer will push or overlay. +* `DrawerContent` - the `` child tag of `` is a `RenderFragment` where you put a component or custom HTML as the content of the Drawer - this is what the drawer will push or overlay. * `SelectedItem` - two-way bindable property that contains the currently selected item in the Drawer. For more information read the [Selection]({%slug drawer-selection%}) article. @@ -117,7 +117,7 @@ The Drawer methods are accessible through it's reference. The reference exposes - lorem ipsum + lorem ipsum @code { diff --git a/components/drawer/refresh-data.md b/components/drawer/refresh-data.md index a93c76f58a..b0abafdb0f 100644 --- a/components/drawer/refresh-data.md +++ b/components/drawer/refresh-data.md @@ -42,12 +42,12 @@ In this article: Mode="DrawerMode.Push" @ref="@DrawerRef" @bind-SelectedItem="@SelectedItem"> - + Toggle drawer
Selected Item: @SelectedItem?.Text
-
+
@code { diff --git a/components/drawer/selection.md b/components/drawer/selection.md index ea5d0179e2..e43715a137 100644 --- a/components/drawer/selection.md +++ b/components/drawer/selection.md @@ -28,12 +28,12 @@ If you use the drawer for [page navigation]({%slug drawer-navigation%}), the sel Mode="@DrawerMode.Push" @bind-SelectedItem="@selectedItem" @ref="@DrawerRef"> - + Toggle drawer
Content for the @selectedItem?.Text item
-
+ @code { diff --git a/components/drawer/templates.md b/components/drawer/templates.md index d0fa520b15..f550fc16b9 100644 --- a/components/drawer/templates.md +++ b/components/drawer/templates.md @@ -43,9 +43,9 @@ This template receives a `context` argument that is of the data model type and r } - + @SelectedItem?.Description - + @@ -84,7 +84,7 @@ When using this template all built-in features of the Drawer are disabled and sh The drawer will expand and collapse as usual, but the content has to be controlled by the application entirely. -Make sure that the `` tag is outside of the `