Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…

Read the release notes

optgroup

Groups related options within a select element under a visible label. Helps users scan long option lists organized into logical categories.

When to Use

  • Organizing options into logical categories (countries by continent, products by type)
  • Long select lists with distinct groupings
  • Making it easier to scan and locate options in a large list

Examples

Grouped options in a dropdown, a disabled group, and groups in a listbox (size greater than 1).

Basic Usage

The required label attribute provides the group heading shown above the options.

Attributes

Attribute Purpose Required
label The group heading text displayed above the options Yes
disabled Disables all options in the group No

Disabled Optgroup

Disabling an optgroup makes every option within it unselectable. This is useful for showing choices that exist but are not currently available.

Styling

In a classic select the open list is drawn by the browser or the operating system. VB sets font-weight: 600 on optgroup (the browser resets the weight of the options inside it); colours, backgrounds and icons are out of reach.

Where customizable select is supported (appearance: base-select, Chromium 135+), VB styles a single-row select's group headings as small, muted, uppercase labels with a divider above every group after the first. The heading looks the same whether it comes from the label attribute or from a <legend> first child. Listbox selects (multiple, or size greater than 1) keep the browser rendering.

Keep the label attribute when you add a <legend>: browsers without customizable select drop the legend, so label is the heading they show and the name assistive technology reads.

Limitations

  • No nesting: You cannot nest an optgroup inside another optgroup. HTML does not support it
  • Content: An optgroup holds option elements, plus an optional leading <legend> in a customizable select
  • Label is required: The label attribute must be provided; there is no fallback text
  • Not in datalist: Optgroups are not supported inside datalist

For fully custom grouped dropdowns with arbitrary styling, consider the combo-box web component.

Accessibility

  • Screen reader support: Browsers expose an optgroup as a group named by its label, and some screen readers announce that name when focus moves into a new group. Not every screen reader and pop-up does, so keep each option understandable on its own
  • Keyboard navigation: Arrow keys move through all options across groups; the group headings cannot be focused or selected
  • Meaningful labels: The label attribute should clearly describe what the group contains
  • Disabled groups: Every option in a disabled group is disabled and announced as unavailable. VB shows disabled options and group headings in GrayText in forced-colors mode

CSS Reference

Related

  • select - Parent element containing optgroups
  • option - Individual choices within groups
  • combo-box - Fully custom filterable dropdown with arbitrary group styling
↑