Skip to Content
Liquid Glass UI
Components

Questionnaire

One-question-at-a-time stepped survey with Apple-styled single/multi-select option cards, keyboard letter/number shortcuts, Liquid Glass text inputs, and Previous / Skip / Next navigation.

Built on @shadcn/react/questionnaire primitives and fully compatible with the standard shadcn/ui JSX API (Questionnaire / QuestionnaireProgress / QuestionnaireItem / QuestionnaireTitle / QuestionnaireDescription / QuestionnaireChoices / QuestionnaireChoice / QuestionnaireInput / QuestionnaireError / QuestionnaireActions and navigation buttons):

  • One question at a time: Displays only the active question; QuestionnaireProgress tracks progress and prevents advancing past unanswered required items with an error prompt.
  • Option cards: Default to Liquid Glass cells reacting to the global glass tint (automatically switching to Over-Glass flat fills inside glass Cards; pass glass={false} for Bordered fills). Selected cards show an accent tint and 1.5px accent border with circular radio dots or rounded-square checkmarks matching RadioGroup / Checkbox.
  • Keyboard shortcuts: Pass shortcuts="letters" or "numbers" on the root to display A / B / C keycaps and enable instant key selection.
  • Native library controls: Text questions render Liquid Glass Input, and navigation buttons render Button with Apple press physics, all automatically adapting to Over-Glass inside glass Cards.
  • Responsive typography: Question title 20px (iOS Title 3) ↔ 15px (macOS), options 17px ↔ 13px, 52px minimum option height on mobile.
apple-liquid-ui/preview/questionnaire-demo
MacBook · 16:10

Installation (Shadcn Registry)

npx shadcn@latest add @apple-liquid/questionnaire

Inside a Glass Card

apple-liquid-ui/preview/questionnaire-card
MacBook · 16:10

Usage

import {
  Questionnaire,
  QuestionnaireActions,
  QuestionnaireChoice,
  QuestionnaireChoices,
  QuestionnaireItem,
  QuestionnaireNext,
  QuestionnairePrevious,
  QuestionnaireProgress,
  QuestionnaireSubmit,
  QuestionnaireTitle,
} from '@/components/ui/questionnaire';

export function Example() {
  return (
    <Questionnaire shortcuts="letters" onSubmit={(event) => event.preventDefault()}>
      <QuestionnaireProgress />
      <QuestionnaireItem name="platform" required>
        <QuestionnaireTitle>Which platform do you primarily use?</QuestionnaireTitle>
        <QuestionnaireChoices>
          <QuestionnaireChoice value="macos">macOS</QuestionnaireChoice>
          <QuestionnaireChoice value="ios">iOS</QuestionnaireChoice>
        </QuestionnaireChoices>
      </QuestionnaireItem>
      <QuestionnaireActions>
        <QuestionnairePrevious>Previous</QuestionnairePrevious>
        <QuestionnaireNext>Next</QuestionnaireNext>
        <QuestionnaireSubmit>Submit</QuestionnaireSubmit>
      </QuestionnaireActions>
    </Questionnaire>
  );
}

QuestionnaireProgress displays "Question 1 of 3" by default and can be customized via its render prop, e.g. render={(props, state) => <div {...props}>Step {state.current} / {state.total}</div>}. Navigation buttons follow <LiquidGlassProvider locale={lang}>.

Props API

Questionnaire

PropTypeDefaultDescription
shortcuts'letters' | 'numbers'—Enable letter or number keyboard shortcuts for choices
defaultItem / itemstring—Initial / controlled active question name
onItemChange(item: string) => void—Callback fired when switching questions
onSubmitFormEventHandler—Native <form> submit handler

QuestionnaireItem

PropTypeDefaultDescription
namestring—Field name for the question (required)
multiplebooleanfalseMulti-select (checkbox) mode
requiredbooleanfalseMarks the question as required

QuestionnaireChoice

PropTypeDefaultDescription
valuestring—Option value (required)
disabledbooleanfalseDisable the option
glassbooleantrueLiquid Glass control material; false renders 100% opaque Bordered fill; auto-switches to Over-Glass on glass surfaces
surface'default' | 'over-glass'Auto-detectedManually override surface context

Navigation buttons (QuestionnairePrevious / QuestionnaireSkip / QuestionnaireNext / QuestionnaireSubmit) support Button's variant and size props (defaulting to outline / ghost / default / default).

Language & Text

Questionnaire accepts locale and messages, which apply to all of its parts and the overlays it opens and win over the global <LiquidGlassProvider locale messages>. To override the text globally, put it under messages.questionnaire on the provider. See Liquid Glass → Global settings.

PropTypeDescription
localeLiquidGlassLocaleInputUI language of this component (any BCP 47 tag; unsupported ones fall back to English)
messagesPartial<QuestionnaireMessages>Text overrides, merged over the built-in text and the global messages.questionnaire
KeyBuilt-in text (English)
previousPrevious
skipSkip
nextNext
submitSubmit

On this page