Learn R Programming

calcite (version 1.0.0)

calcite_option: Create a Calcite Option Component

Description

Option provides a selectable item within a calcite_select() component. Each option represents a single choice in the select dropdown menu.

Usage

calcite_option(label, value, disabled = NULL, selected = NULL, ...)

Value

An object of class calcite_component

Arguments

label

Text label for the option (required for accessibility)

value

The component's value (can be any type)

disabled

When true, interaction is prevented and the component is displayed with lower opacity

selected

When true, the component is selected

...

Additional attributes passed to the component

Details

Options are used within calcite_select() to define the available choices. The value parameter determines what value will be sent to Shiny when the option is selected.

References

Official Documentation

Examples

Run this code
# Basic option
calcite_option(
  label = "First Option",
  value = "1"
)

# Selected option
calcite_option(
  label = "Default Selection",
  value = "default",
  selected = TRUE
)

# Disabled option
calcite_option(
  label = "Unavailable",
  value = "unavailable",
  disabled = TRUE
)

# Use with calcite_select
calcite_select(
  id = "my_select",
  label = "Choose one",
  calcite_option(label = "Option 1", value = "1"),
  calcite_option(label = "Option 2", value = "2", selected = TRUE),
  calcite_option(label = "Option 3", value = "3")
)

Run the code above in your browser using DataLab