Checkbox Groups, Radio Groups, and Date Fields
By the end of this lesson, you'll be able to:
- Use lightning-checkbox-group for multi-select choices
- Use lightning-radio-group for single-select choices
- Use lightning-input date/datetime types for date and time fields
Prerequisites: "Core Input Components: lightning-input, combobox, textarea"
lightning-checkbox-group
<lightning-checkbox-group
label="Interests"
options={interestOptions}
value={selectedInterests}
onchange={handleInterestsChange}>
</lightning-checkbox-group>
For selecting multiple values at once. Note that value here is an array of selected option values, not a single value — a common source of bugs when mixed up with lightning-radio-group below.
lightning-radio-group
<lightning-radio-group
label="Priority"
options={priorityOptions}
value={selectedPriority}
type="radio"
onchange={handlePriorityChange}>
</lightning-radio-group>
For selecting exactly one value among several. value here is a single string, not an array. The type attribute can also be "button" for a segmented-button appearance instead of radio dots.
Date and DateTime Fields
<lightning-input label="Start Date" type="date" value={startDate} onchange={handleStartDateChange}></lightning-input>
<lightning-input label="Appointment Time" type="datetime" value={appointmentTime} onchange={handleTimeChange}></lightning-input>
Still lightning-input, just with type="date" or type="datetime". The underlying value is an ISO 8601-formatted string (e.g. 2026-08-09 or 2026-08-09T14:30:00.000Z) — worth knowing precisely when passing it on to an LDS write (Module 6) or Apex call (Module 7).
Exercise
Write a lightning-checkbox-group for selecting one or more "Preferred Contact Methods" from an options list, bound to a selectedMethods property.
Show hint
Remember the value here is an array.
Exercise
Challenge: explain, as a comment, why mixing up lightning-checkbox-group and lightning-radio-group's value shape (array vs. single string) is a common bug.
Show hint
Think about what happens if you pass an array where a string is expected, or vice versa.
Checkbox Groups, Radio Groups, and Date Fields Quiz
My Notes
Log in to keep private notes on this lesson.
Questions about this lesson
No questions yet — be the first to ask.
Log in to ask a question about this lesson.
Summary
Choice-based inputs and date fields round out the base component toolkit — each with its own value shape worth knowing precisely.