Skip to content

Commit 740e69d

Browse files
ntachevadimodi
andauthored
kb(drawer):add kb for expand/collapse drawer handle (#406)
* kb(drawer):add kb for expand/collapse drawer handle * Update knowledge-base/drawer-add-expand-collapse-handle.md Co-authored-by: Dimo Dimov <[email protected]> * Update knowledge-base/drawer-add-expand-collapse-handle.md Co-authored-by: Dimo Dimov <[email protected]> * Update knowledge-base/drawer-add-expand-collapse-handle.md Co-authored-by: Dimo Dimov <[email protected]> * Update knowledge-base/drawer-add-expand-collapse-handle.md Co-authored-by: Dimo Dimov <[email protected]> * Update knowledge-base/drawer-add-expand-collapse-handle.md Co-authored-by: Dimo Dimov <[email protected]> * Update knowledge-base/drawer-add-expand-collapse-handle.md Co-authored-by: Dimo Dimov <[email protected]> * Update knowledge-base/drawer-add-expand-collapse-handle.md Co-authored-by: Dimo Dimov <[email protected]> Co-authored-by: Dimo Dimov <[email protected]>
1 parent 25e7e72 commit 740e69d

File tree

1 file changed

+100
-0
lines changed

1 file changed

+100
-0
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
---
2+
title: Add Expand/Collapse Handle to Toggle the Drawer
3+
description: This demo shows how to add expand/collapse handle to toggle the Telerik Blazor Drawer.
4+
type: how-to
5+
page_title: Add Expand/Collapse Handle to Toggle the Drawer
6+
slug: drawer-kb-add-expand-collapse-handle
7+
position:
8+
tags: telerik, blazor, drawer, expand, collapse, handle
9+
ticketid: 1527830
10+
res_type: kb
11+
---
12+
13+
## Environment
14+
<table>
15+
<tbody>
16+
<tr>
17+
<td>Product</td>
18+
<td>Drawer for Blazor</td>
19+
</tr>
20+
</tbody>
21+
</table>
22+
23+
24+
## Description
25+
26+
How to add a handle feature within the rendered Drawer component that would expand and collapse the component?
27+
28+
## Solution
29+
30+
To achieve the desired result you can try the following:
31+
32+
* Add a Telerik Button
33+
* Toggle the Drawer on click of that button
34+
* Use custom CSS to adjust the button's appearance, position, transition etc.
35+
36+
The example below demonstrates the described approach:
37+
38+
````CSHTML
39+
@* Add Expand/Collapse handle to toggle the Drawer *@
40+
41+
<style>
42+
.my-toggle-button {
43+
border-radius: 50%;
44+
transform: translateY(50%);
45+
border: 1px solid rgba(0, 0, 0, 0.08);
46+
z-index: 1;
47+
background-color: #fff;
48+
transition-duration:0.3s; /* match the Drawer's animation duration */
49+
}
50+
51+
.my-toggle-button.collapsed {
52+
top: 20px;
53+
left: 34px;
54+
}
55+
56+
.my-toggle-button.expanded {
57+
top: 20px;
58+
left: 225px;
59+
}
60+
</style>
61+
62+
<TelerikButton Class="@(ExpandedDrawer ? "my-toggle-button expanded" : "my-toggle-button collapsed")" Icon="@(ExpandedDrawer ? "chevron-left" : "chevron-right")" OnClick="@(() => DrawerRef.ToggleAsync())"></TelerikButton>
63+
64+
<TelerikDrawer Data="@Data"
65+
Class="my-drawer"
66+
MiniMode="true"
67+
Mode="DrawerMode.Push"
68+
@ref="@DrawerRef"
69+
@bind-SelectedItem="@SelectedItem"
70+
@bind-Expanded="@ExpandedDrawer">
71+
<Content>
72+
@* Place your contents here - it can be as simple as text, it can be conditional components or components that take the selected item as a parameter, or even the @Body tag for navigation if you place the drawer high enough in the project layout hierarchy *@
73+
<div class="m-5">
74+
Selected Item: @SelectedItem?.Text
75+
</div>
76+
</Content>
77+
</TelerikDrawer>
78+
79+
80+
@code {
81+
public bool ExpandedDrawer { get; set; }
82+
83+
TelerikDrawer<DrawerItem> DrawerRef { get; set; }
84+
85+
DrawerItem SelectedItem { get; set; }
86+
87+
IEnumerable<DrawerItem> Data { get; set; } =
88+
new List<DrawerItem>
89+
{
90+
new DrawerItem { Text = "Counter", Icon = "plus"},
91+
new DrawerItem { Text = "FetchData", Icon = "grid-layout"}
92+
};
93+
94+
public class DrawerItem
95+
{
96+
public string Text { get; set; }
97+
public string Icon { get; set; }
98+
}
99+
}
100+
````

0 commit comments

Comments
 (0)