Skip to content

SOptionGroup <s-option-group> ​

Groups related options inside a select under a shared label. SOptionGroup is the typed Vue 3 wrapper for Shopify's Polaris <s-option-group> web component.

ts
import { SOptionGroup } from 'polaris-vue-elements'

Example ​

<SOptionGroup> doesn't render on its own — it groups related <SOption> children under a label inside an <SSelect>.

United StatesCanadaFranceGermany

Value: (none)

vue
<script setup>
import { ref } from 'vue'
import { SSelect, SOption, SOptionGroup } from 'polaris-vue-elements'

const value = ref('')
</script>

<template>
  <SSelect label="Shipping region" placeholder="Select a region" v-model="value">
    <!-- SOptionGroup labels a cluster of SOption children -->
    <SOptionGroup label="North America">
      <SOption value="us">United States</SOption>
      <SOption value="ca">Canada</SOption>
    </SOptionGroup>
    <SOptionGroup label="Europe">
      <SOption value="fr">France</SOption>
      <SOption value="de">Germany</SOption>
    </SOptionGroup>
  </SSelect>
  <p>Value: {{ value }}</p>
</template>

Props ​

PropTypeDescription
disabledbooleanWhether the options within this group can be selected or not.
labelstringThe user-facing label for this group of options.

Slots ​

SlotDescription
defaultThe selectable options displayed in the dropdown list. Accepts option components for individual selectable items within this group.

Released under the MIT License. Vue logo by Evan You, CC BY-NC-SA 4.0.