ButtonGroup
ButtonGroup joins related buttons into one cluster with shared borders. Use it for a set of related actions or a split button. For an input with addons, use InputGroup.
This example also needs: Button.
Installation
Run npx nxds-cli@latest init first if nxds isn’t set up in your app yet. See Install.
Usage
Composition
Examples
Small
Set size="sm" to shrink every member of the group.
Large
Set size="lg" to enlarge every member of the group.
Vertical
Stack the buttons with orientation="vertical".
With text
Add a text prefix with ButtonGroupText.
With separator
Divide ghost buttons into sub-groups with ButtonGroupSeparator.
Props
ButtonGroup
| Prop | Type | Default | Description |
|---|---|---|---|
orientation | "horizontal" | "vertical" | null | "horizontal" | No description |
size | ButtonGroupSize | "default" | Size for ButtonGroupText and any Button without its own |
ButtonGroupSeparator
ButtonGroupSeparator adds no props of its own; it accepts the props of the element or primitive it wraps.
ButtonGroupText
| Prop | Type | Default | Description |
|---|---|---|---|
asChild | boolean | false | Renders the child element instead, such as a link. |
size | ButtonGroupSize | No default documented | Addon size. Inherits from ButtonGroup when omitted, or |
ButtonGroup joins related buttons into one cluster with shared borders. Use it for a set of related actions or a split button. For an input with addons, use InputGroup.
This example also needs: Button.
Installation
Install these components first:
Install the following dependencies:
Copy and paste the following code into your project.
components/button-group/ButtonGroup.vue components/button-group/ButtonGroupSeparator.vue components/button-group/ButtonGroupText.vue components/button-group/button-group-context.ts components/button-group/index.ts Keep each file at the path shown above it.
Paths are relative to
packages/vue/src/. Keep the same folders under your@/root, and the imports between files work without edits.
Usage
Examples
Small
Set size="sm" to shrink every member of the group.
Large
Set size="lg" to enlarge every member of the group.
Vertical
Stack the buttons with orientation="vertical".
With text
Add a text prefix with ButtonGroupText.
With separator
Divide ghost buttons into sub-groups with ButtonGroupSeparator.
This example also needs:
Props
ButtonGroup
| Prop | Type | Default | Description |
|---|---|---|---|
orientation | "vertical" | "horizontal" | null | "horizontal" | No description |
size | ButtonGroupSize | "default" | Size for ButtonGroupText and any Button without its own |
ButtonGroupSeparator
ButtonGroupSeparator adds no props of its own; it accepts the props of the element or primitive it wraps.
ButtonGroupText
| Prop | Type | Default | Description |
|---|---|---|---|
size | ButtonGroupSize | No default documented | Addon size. Inherits from ButtonGroup when omitted, or |