---
title: "Separator · Base UI — StyleX Blocks"
description: "Horizontal and vertical rules in solid, dashed, and dotted weights."
url: "https://stylexblocks.com/components/base-ui/separator/"
agent:
  instructions: "Use this search API to find relevant components and blocks across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://stylexblocks.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Separator

Horizontal and vertical rules in solid, dashed, and dotted weights.

- Behavior engine: Base UI
- Also available for: [Ark UI](https://stylexblocks.com/components/ark-ui/separator.md), [UI SDK](https://stylexblocks.com/components/ui-sdk/separator.md)
- Category: Layout
- Variants: solid, dashed, dotted
- Sizes: xs, sm, md
- HTML page: https://stylexblocks.com/components/base-ui/separator/

## Install

Configure the project once (sets the behavior engine and import aliases):

```sh
npx stylexblocks init --style base-ui
```

Then add the item as source you own:

```sh
npx stylexblocks add separator
```

Equivalent: `npx shadcn add @stylexblocks/separator`. Registry item JSON: https://stylexblocks.com/r/base-ui/separator.json

## Usage

```tsx
import { Separator } from "#components/ui/base-ui/separator.tsx";

export function Example() {
  return (
    {/* variant, orientation, and size resolve through the StyleX recipe
        and surface as data-* attributes */}
    <Separator role="separator" variant="solid" orientation="horizontal" size="sm" />
  );
}
```

## Source

`components/ui/base-ui/separator.tsx`

```tsx
import * as stylex from "@stylexjs/stylex";
import { createComponent } from "#lib/base-ui/create-component.tsx";
import { defineRecipe } from "#lib/recipe-props.ts";
import { semanticColors } from '@stylexblocks/ui/semantic-tokens/colors.stylex.ts'

const separatorStyles = stylex.create({
  base: {
    display: 'block',
    borderColor: semanticColors.border,
  },
})

const separatorVariants = stylex.create({
  solid: {
    borderStyle: 'solid',
  },
  dashed: {
    borderStyle: 'dashed',
  },
  dotted: {
    borderStyle: 'dotted',
  },
})

const separatorOrientations = stylex.create({
  vertical: {
    height: '100%',
    borderInlineStartWidth: 'var(--separator-thickness)',
  },
  horizontal: {
    width: '100%',
    borderTopWidth: 'var(--separator-thickness)',
  },
})

const separatorSizes = stylex.create({
  xs: {
    '--separator-thickness': '0.5px',
  },
  sm: {
    '--separator-thickness': '1px',
  },
  md: {
    '--separator-thickness': '2px',
  },
  lg: {
    '--separator-thickness': '3px',
  },
})

export type SeparatorVariant = keyof typeof separatorVariants

export type SeparatorOrientation = keyof typeof separatorOrientations

export type SeparatorSize = keyof typeof separatorSizes

/**
 * Separator — recipe and component colocated in one file. Variant,
 * orientation, and size props resolve mechanically from the axis maps and
 * surface as data-* attributes; add `role="separator"` (and
 * `aria-orientation` when vertical) at the call site. Composition via
 * `render`.
 */
const separatorRecipe = defineRecipe({
  styles: separatorStyles,
  axes: {
    variant: separatorVariants,
    orientation: separatorOrientations,
    size: separatorSizes,
  },
  defaultVariants: { variant: "solid", orientation: "horizontal", size: "sm" },
});

export const Separator = createComponent("div", separatorRecipe, "Separator");

export type SeparatorProps = React.ComponentProps<typeof Separator>;
```
