# Separator
A thin dividing line. Use it to visually separate sections of a page or items in a toolbar. Like a ruled line on a notepad, it gives your layout breathing room and clarity.
---
## Quick example
```csharp
new Separator() // horizontal rule
new Separator(orientation: "vertical") // vertical bar
```
---
## All the options
```csharp
public Separator(
string orientation = "horizontal",
string extraClasses = "")
```
| Parameter | What it does |
|---|---|
| `orientation` | `"horizontal"` (default) renders an `
`. `"vertical"` renders an inline bar. |
| `extraClasses` | Additional Tailwind classes to override spacing or colour. |
---
## Real-world examples
### Between sections on a settings page
```html
Account
Manage your account details.
$$Sep1$$
Notifications
```
```csharp
_sep1 = new Separator();
```
### Vertical bar in a text editor toolbar
```html
$$Sep$$
$$Sep$$
```
```csharp
_sep = new Separator(orientation: "vertical");
```
### More or less spacing
```csharp
new Separator(extraClasses: "my-8") // extra breathing room above and below
new Separator(extraClasses: "my-2") // tighter spacing
```
---
## How it works
A horizontal separator is an `` element with a top border. A vertical separator is an inline `` with a left border and a fixed height of 16px. Both use `border-border` which follows the theme's CSS variable and adapts to dark mode automatically.
## 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");
}
```