|
| 1 | +--- |
| 2 | +title: Align DateRangePicker Inputs Vertically |
| 3 | +description: Learn how to modify the layout of the DateRangePicker in Blazor to display its inputs vertically using custom CSS. |
| 4 | +type: how-to |
| 5 | +page_title: How to Display DateRangePicker Inputs Vertically |
| 6 | +slug: daterangepicker-kb-vertical-input-alignment |
| 7 | +tags: datarangepicker, blazor, css, layout, vertical, align |
| 8 | +res_type: kb |
| 9 | +ticketid: 1656293 |
| 10 | +--- |
| 11 | + |
| 12 | +## Environment |
| 13 | + |
| 14 | +<table> |
| 15 | + <tbody> |
| 16 | + <tr> |
| 17 | + <td>Product</td> |
| 18 | + <td>DateRangePicker for Blazor</td> |
| 19 | + </tr> |
| 20 | + </tbody> |
| 21 | +</table> |
| 22 | + |
| 23 | +## Description |
| 24 | + |
| 25 | +This KB article answers the following questions: |
| 26 | +- How to change the layout of DateRangePicker inputs in Blazor, so they appear vertically oriented? |
| 27 | +- Can I display DateRangePicker inputs vertically in Blazor? |
| 28 | +- Is there a way to adjust the DateRangePicker so the inputs appear on two lines, one on top of each other? |
| 29 | + |
| 30 | +## Solution |
| 31 | + |
| 32 | +To align the inputs of the DateRangePicker vertically, apply custom CSS to adjust the component's layout. Follow these steps: |
| 33 | + |
| 34 | +1. Add a custom CSS class to the DateRangePicker through the `Class` parameter. |
| 35 | +2. Use the custom class to target the wrapping element of the DateRangePicker and apply the necessary styles. |
| 36 | +3. (Optional) Adjust the popup calendar orientation if needed. |
| 37 | + |
| 38 | +Here is an example implementation: |
| 39 | + |
| 40 | +```CSHTML |
| 41 | +<style> |
| 42 | + .vertical-picker { |
| 43 | + flex-direction: column; |
| 44 | + align-items: baseline; |
| 45 | + width: 140px; |
| 46 | + } |
| 47 | +</style> |
| 48 | +
|
| 49 | +<TelerikDateRangePicker @bind-StartValue="@StartValue" |
| 50 | + @bind-EndValue="@EndValue" |
| 51 | + Class="vertical-picker" |
| 52 | + Orientation="CalendarOrientation.Vertical"> |
| 53 | +</TelerikDateRangePicker> |
| 54 | +
|
| 55 | +@code { |
| 56 | + private DateTime? StartValue { get; set; } = DateTime.Today; |
| 57 | + private DateTime? EndValue { get; set; } = DateTime.Today.AddDays(10); |
| 58 | +} |
| 59 | +``` |
| 60 | + |
| 61 | +This CSS ensures that the labels and inputs of the DateRangePicker display one below the other. Adjust the styles as needed to fit your design requirements better. Additionally, consider [repositioning the labels so they appear on the side and not on top of the inputs]({%slug daterangepicker-kb-reposition-labels%}). |
| 62 | + |
| 63 | +## See Also |
| 64 | + |
| 65 | +- [Repositioning Labels in DateRangePicker](https://docs.telerik.com/blazor-ui/knowledge-base/daterangepicker-reposition-labels) |
| 66 | +- [DateRangePicker Overview](https://docs.telerik.com/blazor-ui/components/daterangepicker/overview) |
0 commit comments