Separator
Creates a visual or semantic boundary between adjacent groups of content.
Preview
Example code
OverviewActivity
Playground
orientationSets the divider axis.
decorativeRemoves separator semantics when it is purely visual.
Usage
tsx
import { Separator } from "earthling-ui/separator";
export function Example() {
return (
<>
<Separator decorative={false} aria-label="Section divider" />
</>
);
}
- Keep decorative true when the surrounding structure already communicates the grouping.
- Set decorative to false only when the separator conveys structure, and give it an accessible label when useful.
- Vertical separators need a parent with an explicit height.
Installation
Start with the project setup for React and Tailwind CSS 4. Both paths use the same component and theme.
Import package
Own the source
bash
npm install earthling-uiUse the component import shown above. Package updates keep the implementation current.
API reference
Declarations from the current library build, including inherited primitive props. Playground controls above show selected options; they are not the complete API.
tsx
// Generated by dts-bundle-generator v9.5.1
import * as SeparatorPrimitive from '@radix-ui/react-separator';
export declare const Separator: import("react").ForwardRefExoticComponent<Omit<SeparatorPrimitive.SeparatorProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
export {};Runtime dependencies: @radix-ui/react-separator, cnfast.
Source
Use the eject command to copy this implementation with its required helpers and project-specific imports.
View Separator implementation
tsx
"use client";
import {
forwardRef,
type ComponentPropsWithoutRef,
type ComponentRef,
} from "react";
import * as SeparatorPrimitive from "@radix-ui/react-separator";
import { cn } from "@/utils/cn";
const Separator = forwardRef<
ComponentRef<typeof SeparatorPrimitive.Root>,
ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>
>(
(
{ className, orientation = "horizontal", decorative = true, ...props },
ref
) => (
<SeparatorPrimitive.Root
ref={ref}
decorative={decorative}
orientation={orientation}
className={cn(
"shrink-0 bg-current/15",
orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
className
)}
{...props}
/>
)
);
Separator.displayName = SeparatorPrimitive.Root.displayName;
export { Separator };