Skip to content

Multiple choice ​

This component is a simple component that prompts the user to select several option among many.

PropertyValue
InteractivityRequired (fails otherwise)

Demo ​

A gif that shows the component in action. The developer uses the key strokes up and down arrows to move their selection and select items

API ​

Example with a case iterable enum ​

swift
enum ProjectTargets: String, CaseIterable, CustomStringConvertible {
    case alpha
    case beta
    case gamma
    case delta

    var description: String {
        switch self {
        case .alpha:
            return "Alpha"
        case .beta:
            return "Beta"
        case .gamma:
            return "Gamma"
        case .delta:
            return "Delta"
        }
    }
}

let selection: [ProjectTargets] = Noora(theme: Theme.default).multipleChoicePrompt(
    title: "Migration",
    question: "Select targets for migration to Tuist.",
    description: "You can select up to 3 targets for migration.",
    maxLimit: .limited(count: 3, errorMessage: "You can select up to 3 targets."),
    minLimit: .limited(count: 1, errorMessage: "You need to select at least 1 target.")
)

Options ​

AttributeDescriptionRequiredDefault value
titleThe title of the prompt.No
questionThe question that the user will answer.Yes
descriptionA description that provides more context about the question.No
collapseOnSelectionWhether the prompt should collapse after the user selects an option.Notrue
filterModeWhether the list of options should be filterable.Nodisabled
maxLimitUse to limit maximum selected options count.Nounlimited
minLimitUse to limit minimum selected options count.Nounlimited

Released under the MIT License.