Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions apps/www/src/content/docs/components/separator/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,3 @@ The Separator component supports three sizes.
Separator can be rendered in both horizontal and vertical orientations.

<Demo data={orientationDemo} />

## Accessibility

The Separator component follows accessibility best practices:

- Uses `role="separator"` by default
- Is marked as `decorative` for visual separation
- Maintains proper color contrast
- Supports proper semantic structure in both orientations
13 changes: 13 additions & 0 deletions apps/www/src/content/docs/components/separator/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,17 @@ export interface SeparatorProps {

/** Additional CSS class names. */
className?: string;

/**
* Allows you to replace the component's HTML element with a different tag, or compose it with another component.
* Accepts a `ReactElement` or a function that returns the element to render.
*
* @remarks `ReactElement | function`
*/
render?:
| React.ReactElement
| ((
props: React.HTMLAttributes<HTMLElement>,
state: { orientation: 'horizontal' | 'vertical' }
) => React.ReactElement);
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,28 +79,16 @@ describe('Separator', () => {
expect(screen.getByRole('separator')).toBeInTheDocument();
});

it('has default aria-label for horizontal separator', () => {
render(<Separator />);
const separator = screen.getByRole('separator');
expect(separator).toHaveAttribute('aria-label', 'horizontal separator');
});

it('has default aria-label for vertical separator', () => {
render(<Separator orientation='vertical' />);
const separator = screen.getByRole('separator');
expect(separator).toHaveAttribute('aria-label', 'vertical separator');
});

it('supports custom aria-label', () => {
render(<Separator aria-label='Section divider' />);
const separator = screen.getByRole('separator');
expect(separator).toHaveAttribute('aria-label', 'Section divider');
});

it('is marked as decorative', () => {
it('has aria-orientation attribute', () => {
render(<Separator />);
const separator = screen.getByRole('separator');
expect(separator).toHaveAttribute('aria-orientation');
expect(separator).toHaveAttribute('aria-orientation', 'horizontal');
});
});
});
14 changes: 3 additions & 11 deletions packages/raystack/components/separator/separator.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Separator as SeparatorPrimitive } from '@base-ui/react/separator';
import { cva } from 'class-variance-authority';
import { Separator as SeparatorPrimitive } from 'radix-ui';

import styles from './separator.module.css';

Expand All @@ -22,30 +22,22 @@ const separator = cva(styles.separator, {
}
});

interface SeparatorProps {
className?: string;
orientation?: 'horizontal' | 'vertical';
interface SeparatorProps extends SeparatorPrimitive.Props {
size?: 'small' | 'half' | 'full';
color?: 'primary' | 'secondary' | 'tertiary';
'aria-label'?: string;
}

export function Separator({
className,
orientation = 'horizontal',
size,
color,
'aria-label': ariaLabel,
...props
}: SeparatorProps) {
return (
<SeparatorPrimitive.Root
decorative
<SeparatorPrimitive
orientation={orientation}
className={separator({ size, color, className })}
aria-orientation={orientation}
aria-label={ariaLabel || `${orientation} separator`}
role='separator'
{...props}
/>
);
Expand Down