Alignment in Blazor Timeline component
20 Mar 20246 minutes to read
You can display the Timeline content Before
, After
, Alternate
and AlternateReverse
by using the Alignment property. The oppositeContent will be displayed parallel to the content when configured in the TimelineItem directive.
Before
In Before alignment, for horizontal
orientation the item content is placed at the top and oppositeContent at the bottom whereas in vertical
, the content to the left and oppositeContent to the right.
@using Syncfusion.Blazor.Layouts
<div class="container" style="height: 350px">
<SfTimeline Alignment="TimelineAlignment.Before">
<TimelineItems>
@foreach (var item in timelineItems)
{
<TimelineItem>
<Content> @item.Content </Content>
<OppositeContent> @item.OppositeContent </OppositeContent>
</TimelineItem>
}
</TimelineItems>
</SfTimeline>
</div>
@code {
public class TimelineItemModel
{
public string Content { get; set; }
public string OppositeContent { get; set; }
}
private List<TimelineItemModel> timelineItems = new List<TimelineItemModel>()
{
new TimelineItemModel() { Content = "ReactJs", OppositeContent = "Owned by Facebook" },
new TimelineItemModel() { Content = "Angular", OppositeContent = "Owned by Google" },
new TimelineItemModel() { Content = "VueJs", OppositeContent = "Owned by Evan you" },
new TimelineItemModel() { Content = "Svelte", OppositeContent = "Owned by Rich Harris" }
};
}
After
In After alignment, for horizontal
orientation the item content is placed at the bottom and oppositeContent at the top whereas in vertical
, the content to the right and oppositeContent to the left.
@using Syncfusion.Blazor.Layouts
<div class="container" style="height: 350px">
<SfTimeline Alignment="TimelineAlignment.After">
<TimelineItems>
@foreach (var item in timelineItems)
{
<TimelineItem>
<Content> @item.Content </Content>
<OppositeContent> @item.OppositeContent </OppositeContent>
</TimelineItem>
}
</TimelineItems>
</SfTimeline>
</div>
@code {
public class TimelineItemModel
{
public string Content { get; set; }
public string OppositeContent { get; set; }
}
private List<TimelineItemModel> timelineItems = new List<TimelineItemModel>()
{
new TimelineItemModel() { Content = "ReactJs", OppositeContent = "Owned by Facebook" },
new TimelineItemModel() { Content = "Angular", OppositeContent = "Owned by Google" },
new TimelineItemModel() { Content = "VueJs", OppositeContent = "Owned by Evan you" },
new TimelineItemModel() { Content = "Svelte", OppositeContent = "Owned by Rich Harris" }
};
}
Alternate
In Alternate alignment, the item content are arranged alternatively regardless of the Timeline orientation.
@using Syncfusion.Blazor.Layouts
<div class="container" style="height: 350px">
<SfTimeline Alignment="TimelineAlignment.Alternate">
<TimelineItems>
@foreach (var item in timelineItems)
{
<TimelineItem>
<Content> @item.Content </Content>
<OppositeContent> @item.OppositeContent </OppositeContent>
</TimelineItem>
}
</TimelineItems>
</SfTimeline>
</div>
@code {
public class TimelineItemModel
{
public string Content { get; set; }
public string OppositeContent { get; set; }
}
private List<TimelineItemModel> timelineItems = new List<TimelineItemModel>()
{
new TimelineItemModel() { Content = "ReactJs", OppositeContent = "Owned by Facebook" },
new TimelineItemModel() { Content = "Angular", OppositeContent = "Owned by Google" },
new TimelineItemModel() { Content = "VueJs", OppositeContent = "Owned by Evan you" },
new TimelineItemModel() { Content = "Svelte", OppositeContent = "Owned by Rich Harris" }
};
}
Alternate reverse
In AlternateReverse alignment, the item content are arranged in reverse alternate regardless of the Timeline orientation.
@using Syncfusion.Blazor.Layouts
<div class="container" style="height: 350px">
<SfTimeline Alignment="TimelineAlignment.Before">
<TimelineItems>
@foreach (var item in timelineItems)
{
<TimelineItem>
<Content> @item.Content </Content>
<OppositeContent> @item.OppositeContent </OppositeContent>
</TimelineItem>
}
</TimelineItems>
</SfTimeline>
</div>
@code {
public class TimelineItemModel
{
public string Content { get; set; }
public string OppositeContent { get; set; }
}
private List<TimelineItemModel> timelineItems = new List<TimelineItemModel>()
{
new TimelineItemModel() { Content = "ReactJs", OppositeContent = "Owned by Facebook" },
new TimelineItemModel() { Content = "Angular", OppositeContent = "Owned by Google" },
new TimelineItemModel() { Content = "VueJs", OppositeContent = "Owned by Evan you" },
new TimelineItemModel() { Content = "Svelte", OppositeContent = "Owned by Rich Harris" }
};
}