# Separator A thin divider line. Renders as a horizontal `
` or a vertical bar depending on orientation. --- ## HTML structure **Horizontal:** ``` hr.border-t.border-border.my-4.{extraClasses} ``` **Vertical:** ``` span.inline-block.border-l.border-border.mx-2.h-4.{extraClasses} ``` --- ## CSS mechanics | Class | Effect | |---|---| | `border-t border-border` | Top border in the theme's border color (horizontal) | | `border-l border-border` | Left border in the theme's border color (vertical) | | `my-4` | Default vertical margin for horizontal separators | | `mx-2` | Default horizontal margin for vertical separators | | `h-4` | 16px height for vertical separators | --- ## Constructor signature ```csharp public Separator( string orientation = "horizontal", string extraClasses = "") ``` | Parameter | Description | |---|---| | `orientation` | `"horizontal"` (default) or `"vertical"` | | `extraClasses` | Additional Tailwind classes on the element | --- ## Usage examples ### Horizontal divider ```csharp new Separator() ``` ### Vertical divider in a flex toolbar ```html
$$VertSep$$ $$VertSep$$
``` ```csharp var VertSep = new Separator(orientation: "vertical"); ``` ### Custom margin ```csharp new Separator(extraClasses: "my-8") // extra vertical space new Separator(extraClasses: "my-0 mt-2") // override default margin ``` --- ## Tips and tricks - The horizontal `Separator` is an `
` element — it carries semantic meaning as a thematic break. Use it between content sections. - The vertical `Separator` is an inline `` — use it inside `flex` rows (toolbars, breadcrumb rows, stat rows, etc.). - Override margins using `extraClasses` when the default `my-4` / `mx-2` doesn't fit the surrounding layout. - Override margins using `extraClasses` when the default `my-4` / `mx-2` doesn't fit the surrounding layout. --- ## Complete page example **`Templates/AboutPage.htmx`** ```html

About BeepBoop

A fast AOT-safe HTMX framework for .NET 10.

$$SectionSep1$$

Mission

$$MissionText$$

$$SectionSep2$$

Team

Alice $$InlineSep$$ Bob $$InlineSep$$ Carol
``` **`Templates/AboutPage.htmx.cs`** ```csharp namespace Htmx.ApiDemo.Templates; public sealed class AboutPage : AboutPageBase { private readonly IHtmxComponent _sep1; private readonly IHtmxComponent _sep2; private readonly IHtmxComponent _inline; private readonly byte[] _mission; public AboutPage() { _sep1 = new Components.Separator(); _sep2 = new Components.Separator(); _inline = new Components.Separator(orientation: "vertical"); _mission = "BeepBoop makes building server-rendered HTMX apps as fast and safe as possible.".ToUtf8Bytes(); } protected override void RenderSectionSep1(HtmxRenderContext ctx) => _sep1.Render(ctx.Next()); protected override void RenderSectionSep2(HtmxRenderContext ctx) => _sep2.Render(ctx.Next()); protected override void RenderInlineSep(HtmxRenderContext ctx) => _inline.Render(ctx.Next()); protected override void RenderMissionText(HtmxRenderContext ctx) => ctx.Writer.WriteUtf8(_mission); } ``` **GET handler** ```csharp [Handler] [MapGet("/about")] public static partial class GetAboutHandler { public record Query(); private static Task HandleAsync(Query _, HttpContext ctx, CancellationToken ct) => ctx.WriteHtmxPage(new AboutPage(), title: "About"); } ```