WlButtonGroup

Visually grouped buttons (role=group).
Components / Actions v0.1.0

Change props to see the result: the example and code use the same settings. “Reset” restores the initial values.

Settings

ariaLabel

Group aria-label.

Join adjacent button borders and corners into one group.

Props size, variant, density, models, handlers and slots can be edited in the SFC. See their descriptions in API.

Example

Focus: outside the example · pointer: outside the example

Explore the live example and copy its Vue SFC into your application. Settings on the left can be combined.

Code for your application

Vue SFC · current settings
<script setup lang="ts">
import { WlButton, WlButtonGroup } from "legato-ui";
import { ref } from "vue";
const selected = ref("day");
</script>

<template>
  <div class="wl-stack" data-space="md">
    <WlButtonGroup aria-label="Period" >
      <WlButton :variant="selected === 'day' ? 'primary' : 'secondary'" @click="selected = 'day'">
        {{ "Day" }}
      </WlButton>
      <WlButton :variant="selected === 'week' ? 'primary' : 'secondary'" @click="selected = 'week'">
        {{ "Week" }}
      </WlButton>
    </WlButtonGroup>
  </div>
</template>

Action and navigation groups

Related period buttons and an icon group with disabled endpoint pages; the application stores state.

Period: Day. Page: 1 of 5.

The group joins buttons with a shared border and sets role="group". The application stores the selected mode.

Vue SFC · additional example
<script setup lang="ts">
import { WlButton, WlButtonGroup, WlIconButton } from "legato-ui";
import { ref } from "vue";
const period = ref("Day");
const page = ref(1);
</script>

<template>
  <div class="wl-stack" data-space="lg">
    <div><WlButtonGroup aria-label="Report period"><WlButton
      v-for="label in ['Day', 'Week', 'Month']"
      :key="label"
      size="sm"
      :variant="period === label ? 'primary' : 'secondary'"
      :aria-pressed="period === label"
      @click="period = label"
    >{{ label }}</WlButton></WlButtonGroup></div>
    <div><WlButtonGroup aria-label="Report pages"><WlIconButton
      icon="chevron-left"
      variant="secondary"
      aria-label="Previous report page"
      :disabled="page === 1"
      @click="page--"
    /><WlIconButton
      icon="chevron-right"
      variant="secondary"
      aria-label="Next report page"
      :disabled="page === 5"
      @click="page++"
    /></WlButtonGroup></div>
    <p class="wl-text-small" role="status">
      {{ "Period:" }} {{ period }}{{ ". Page:" }} {{ page }} {{ "of 5." }}
    </p>
    <p class="wl-text-small wl-text-muted">{{ "The group joins buttons with a shared border and sets role=\"group\". The application stores the selected mode." }}</p>
  </div>
</template>