diff --git a/apps/www/src/content/docs/components/separator/index.mdx b/apps/www/src/content/docs/components/separator/index.mdx index 3f7609c0e..af77f90cd 100644 --- a/apps/www/src/content/docs/components/separator/index.mdx +++ b/apps/www/src/content/docs/components/separator/index.mdx @@ -37,12 +37,3 @@ The Separator component supports three sizes. Separator can be rendered in both horizontal and vertical orientations. - -## 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 diff --git a/apps/www/src/content/docs/components/separator/props.ts b/apps/www/src/content/docs/components/separator/props.ts index 896b961c9..c6a7f2dde 100644 --- a/apps/www/src/content/docs/components/separator/props.ts +++ b/apps/www/src/content/docs/components/separator/props.ts @@ -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, + state: { orientation: 'horizontal' | 'vertical' } + ) => React.ReactElement); } diff --git a/packages/raystack/components/separator/__tests__/separator.test.tsx b/packages/raystack/components/separator/__tests__/separator.test.tsx index 84ec9be8b..9fbc6c7e1 100644 --- a/packages/raystack/components/separator/__tests__/separator.test.tsx +++ b/packages/raystack/components/separator/__tests__/separator.test.tsx @@ -79,28 +79,16 @@ describe('Separator', () => { expect(screen.getByRole('separator')).toBeInTheDocument(); }); - it('has default aria-label for horizontal separator', () => { - render(); - const separator = screen.getByRole('separator'); - expect(separator).toHaveAttribute('aria-label', 'horizontal separator'); - }); - - it('has default aria-label for vertical separator', () => { - render(); - const separator = screen.getByRole('separator'); - expect(separator).toHaveAttribute('aria-label', 'vertical separator'); - }); - it('supports custom aria-label', () => { render(); const separator = screen.getByRole('separator'); expect(separator).toHaveAttribute('aria-label', 'Section divider'); }); - it('is marked as decorative', () => { + it('has aria-orientation attribute', () => { render(); const separator = screen.getByRole('separator'); - expect(separator).toHaveAttribute('aria-orientation'); + expect(separator).toHaveAttribute('aria-orientation', 'horizontal'); }); }); }); diff --git a/packages/raystack/components/separator/separator.tsx b/packages/raystack/components/separator/separator.tsx index 9aef13b14..fb98b3db7 100644 --- a/packages/raystack/components/separator/separator.tsx +++ b/packages/raystack/components/separator/separator.tsx @@ -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'; @@ -22,12 +22,9 @@ 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({ @@ -35,17 +32,12 @@ export function Separator({ orientation = 'horizontal', size, color, - 'aria-label': ariaLabel, ...props }: SeparatorProps) { return ( - );