// Generated by scripts/generate-showcase.mjs. Do not edit directly. page ButtonGroupDetail { layout = "showcase" state playground_items = JSON.parse(ctx.url.searchParams.get("pg_items") ?? "[{\"label\":\"Day\",\"value\":\"day\"},{\"label\":\"Week\",\"value\":\"week\"},{\"label\":\"Month\",\"value\":\"month\"}]") state playground_value = ctx.url.searchParams.get("pg_value") ?? "week" state playground_size = ctx.url.searchParams.get("pg_size") ?? "md" state playground_color = ctx.url.searchParams.get("pg_color") ?? "primary" state playground_variant = ctx.url.searchParams.get("pg_variant") ?? "default" state playground_orientation = ctx.url.searchParams.get("pg_orientation") ?? "horizontal" state playground_responsive = (ctx.url.searchParams.get("pg_responsive") ?? "false") === "true" state playground_attached = (ctx.url.searchParams.get("pg_attached") ?? "true") === "true" state playground_selectable = (ctx.url.searchParams.get("pg_selectable") ?? "true") === "true" state playground_toolbar = (ctx.url.searchParams.get("pg_toolbar") ?? "false") === "true" state playground_disabled = (ctx.url.searchParams.get("pg_disabled") ?? "false") === "true" state playground_ariaLabel = ctx.url.searchParams.get("pg_ariaLabel") ?? "Button group" state playground_class = ctx.url.searchParams.get("pg_class") ?? "" seo { title = "Button Group" description = "Theme-aware, responsive button group component." } view {
Base component

Button Group

Theme-aware, responsive button group component.

13 props1 slots3 outputsTheme readyResponsive
Interactive playground

Configure Button Group

Change any prop and inspect the server-rendered component immediately.

Live preview
Component code
page ButtonGroupExample {
  state items = [
  {
    "label": "Day",
    "value": "day"
  },
  {
    "label": "Week",
    "value": "week"
  },
  {
    "label": "Month",
    "value": "month"
  }
]
  view {
    <ButtonGroup
      items="{items}"
      value="week"
      selectable="true"
    />
  }
}
Event outputInteract with the preview to inspect the typed payload.
Component props13 controls
Live examples

Designed for real product surfaces

Compare configurations and resize the browser to check responsive behavior.

Recommended

Production default

Balanced spacing, hierarchy, and content for the most common product workflow.

01
Live preview
Component usage.wrn
page ButtonGroupExample {
  state items = [
  {
    "label": "Day",
    "value": "day"
  },
  {
    "label": "Week",
    "value": "week"
  },
  {
    "label": "Month",
    "value": "month"
  }
]
  view {
    <ButtonGroup
      items="{items}"
      value="week"
      selectable="true"
    />
  }
}
Dense UI

Compact application

A tighter variation for dashboards, side panels, tables, and operational interfaces.

02
Live preview
Component usage.wrn
page ButtonGroupExample {
  state items = [
  {
    "label": "Day",
    "value": "day"
  },
  {
    "label": "Week",
    "value": "week"
  },
  {
    "label": "Month",
    "value": "month"
  }
]
  view {
    <ButtonGroup
      items="{items}"
      value="week"
      size="sm"
      selectable="true"
    />
  }
}
Extended

Rich configuration

A more expressive variation using additional data, stronger emphasis, and optional states.

03
Live preview
Component usage.wrn
page ButtonGroupExample {
  state items = [
  {
    "label": "Day",
    "value": "day"
  },
  {
    "label": "Week",
    "value": "week"
  },
  {
    "label": "Month",
    "value": "month"
  }
]
  view {
    <ButtonGroup
      items="{items}"
      value="week"
      attached="false"
      selectable="true"
    />
  }
}
Component outputs

Receive every typed component output

Use declarative output handlers in .wrn files or register a direct output handler from JavaScript. The canonical API exposes payload and does not require event.detail.

@clickFires when the interactive surface is activated.
@selectFires when an item, option, card, or result is selected.
@changeFires when the component's committed value or selection changes.
Declarative handlers.wrn
<ButtonGroup
  @click='console.log(payload)'
  @select='console.log(payload)'
  @change='console.log(payload)'
/>
Direct output handlers.js
import { registerOutputHandler } from "@wrnexus/csr/outputs"

const component = document.querySelector("[data-ui-component=\"ButtonGroup\"], [data-component=\"ButtonGroup\"]")

if (component) registerOutputHandler(component, "click", (payload) => {
  console.log("click", payload)
})

if (component) registerOutputHandler(component, "select", (payload) => {
  console.log("select", payload)
})

if (component) registerOutputHandler(component, "change", (payload) => {
  console.log("change", payload)
})
Component API

Props and configuration

All content and behavior shown above is supplied through these props and slots.

PropTypeDefaultRequired
itemsunknown[][]No
valuestring""No
sizestring"md"No
colorstring"primary"No
variantstring"default"No
orientationstring"horizontal"No
responsivebooleanfalseNo
attachedbooleantrueNo
selectablebooleanfalseNo
toolbarbooleanfalseNo
disabledbooleanfalseNo
ariaLabelstring"Button group"No
classstring""No
} }