Skip to main content
Decoderen
Browse documentation

Divider

Separate related content with a semantic hairline.

Horizontal


Show code
Example.astroAstro
---
import Divider from '@dhekode/ui/primitives/Divider.tsx';
---

<Divider />

Vertical

DesignEngineering
Show code
Example.astroAstro
---
import Divider from '@dhekode/ui/primitives/Divider.tsx';
---

<div class="dk-demo-row"><span>Design</span><Divider orientation="vertical" /><span>Engineering</span></div>
<style>
  .dk-demo-row { display: flex; align-items: center; gap: var(--dk-space-md); }
</style>
API reference
orientation

Type: 'horizontal' | 'vertical'

Default: 'horizontal'

Full-width horizontal rule or a compact vertical separator.

className

Type: string | undefined

Default: unset

Adds classes to the React component root, after its own utilities. React components take className, not class.

Slots: None.

Use sparingly when spacing alone does not communicate a boundary.

Original component source
packages/ui/src/primitives/Divider.tsxAstro
import { classNames } from '@dhekode/utils/class-names';

export interface DividerProps {
  orientation?: 'horizontal' | 'vertical' | undefined;
  className?: string | undefined;
}

/** Material 3's divider: a hairline in the surface's border colour. */
export default function Divider({ orientation = 'horizontal', className }: DividerProps) {
  const shared = 'dk-divider m-0 shrink-0 border-0 bg-surface-border';
  if (orientation === 'vertical') {
    return (
      <div
        role="separator"
        aria-orientation="vertical"
        className={classNames(shared, 'h-3xl w-(--dk-border-width-hairline)', className)}
        data-orientation="vertical"
      />
    );
  }
  return (
    <hr
      className={classNames(shared, 'h-(--dk-border-width-hairline) w-full', className)}
      data-orientation="horizontal"
    />
  );
}