diff --git a/src/components/stepindicator/StepIndicator/StepIndicator.stories.tsx b/src/components/stepindicator/StepIndicator/StepIndicator.stories.tsx index 49495f6412..24606d5b73 100644 --- a/src/components/stepindicator/StepIndicator/StepIndicator.stories.tsx +++ b/src/components/stepindicator/StepIndicator/StepIndicator.stories.tsx @@ -64,3 +64,13 @@ export const smallCounters = (): React.ReactElement => ( ) + +export const customHeadingLevel = (): React.ReactElement => ( + + + + + + + +) diff --git a/src/components/stepindicator/StepIndicator/StepIndicator.test.tsx b/src/components/stepindicator/StepIndicator/StepIndicator.test.tsx index 38e7394c58..669a59b0d3 100644 --- a/src/components/stepindicator/StepIndicator/StepIndicator.test.tsx +++ b/src/components/stepindicator/StepIndicator/StepIndicator.test.tsx @@ -110,4 +110,34 @@ describe('StepIndicator component', () => { expect(queryByText(step3)).toBeInTheDocument() expect(getByRole('list')).toHaveClass('usa-step-indicator__segments') }) + + it('renders properly with a passed in heading level', () => { + const { getByRole, queryByTestId } = render( + + + + + + ) + + const stepIndicator = queryByTestId('step-indicator') + + expect(stepIndicator).toBeInTheDocument() + expect(getByRole('heading', { level: 2 })).toBeInTheDocument() + }) + + it('renders properly with a default heading level', () => { + const { getByRole, queryByTestId } = render( + + + + + + ) + + const stepIndicator = queryByTestId('step-indicator') + + expect(stepIndicator).toBeInTheDocument() + expect(getByRole('heading', { level: 4 })).toBeInTheDocument() + }) }) diff --git a/src/components/stepindicator/StepIndicator/StepIndicator.tsx b/src/components/stepindicator/StepIndicator/StepIndicator.tsx index db27870684..2b5776be2b 100644 --- a/src/components/stepindicator/StepIndicator/StepIndicator.tsx +++ b/src/components/stepindicator/StepIndicator/StepIndicator.tsx @@ -10,6 +10,7 @@ interface StepIndicatorProps { className?: string divProps?: JSX.IntrinsicElements['div'] listProps?: JSX.IntrinsicElements['ol'] + headingLevel?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' } export const StepIndicator = ( props: StepIndicatorProps @@ -22,8 +23,11 @@ export const StepIndicator = ( className, divProps, listProps, + headingLevel = 'h4', } = props + const Heading = headingLevel + const classes = classnames( 'usa-step-indicator', { @@ -54,7 +58,7 @@ export const StepIndicator = ( {children}
-

+ Step @@ -67,7 +71,7 @@ export const StepIndicator = ( {currentStepLabel} -

+
)