shadimage
quiz-ui
componentquiz-navigationsource: ok · hit

QuizNavigation

Back/Next controls; Next disables automatically until the step is answered.

npx shadcn add "https://quiz-ui-phi.vercel.app/r/quiz-navigation.json"
free

No selection tags yet — empty means no evidence, not lack of support.

Dependencies

Bundle weight · light

Registry dependencies

@quiz-ui/quiz-core@quiz-ui/quiz-cn

Files1 · source cached 10/9/2026, 12:42:30 PM

components/ui/quiz/quiz-navigation.tsx
"use client";

import * as React from "react";
import { useQuizStep } from "./core";

export interface QuizNavigationProps {
  nextLabel?: string;
  backLabel?: string;
  hideBack?: boolean;
  /** Applied to the row wrapping both buttons. */
  className?: string;
  backButtonClassName?: string;
  nextButtonClassName?: string;
}

export function QuizNavigation({
  nextLabel = "Next",
  backLabel = "Back",
  hideBack = false,
  className,
  backButtonClassName,
  nextButtonClassName,
}: QuizNavigationProps) {
  const { isAnswered, advance, back, canGoBack } = useQuizStep();

  return (
    <div className={className}>
      {!hideBack && canGoBack ? (
        <button type="button" onClick={back} className={backButtonClassName}>
          {backLabel}
        </button>
      ) : (
        <span />
      )}
      <button
        type="button"
        onClick={advance}
        disabled={!isAnswered}
        className={nextButtonClassName}
      >
        {nextLabel}
      </button>
    </div>
  );
}

More from quiz-ui

Browse all components in this library →