/**
* Divider (web). A line. Horizontal by default; pass orientation="vertical"
* to split a row. Optional inline label sits in the middle.
*
*
*
* ......
*/
import type { CSSProperties, ReactNode } from "react";
import { useTheme } from "@plyxui/styles";
import { spacing } from "@plyxui/core";
export interface DividerProps {
orientation?: "horizontal" | "vertical";
/** Inline label split-mode. Only meaningful for horizontal. */
label?: ReactNode;
/** Indent the line from the edge. Pixels. */
inset?: number;
/** Override the line color. Defaults to colors.stroke. */
color?: string;
/** Line thickness in pixels. Default 1. */
thickness?: number;
/** "dashed" or "solid". Default "solid". */
style?: "solid" | "dashed";
className?: string;
}
export function Divider({
orientation = "horizontal",
label,
inset = 0,
color,
thickness = 1,
style: variant = "solid",
className,
}: DividerProps) {
const { colors } = useTheme();
const lineColor = color ?? colors.stroke;
if (orientation === "vertical") {
const style: CSSProperties = {
alignSelf: "stretch",
width: thickness,
borderLeft: `${thickness}px ${variant} ${lineColor}`,
marginTop: inset,
marginBottom: inset,
};
return
;
}
if (label) {
return (
{label}
);
}
return (
);
}