Components/GroupBlock

GroupBlock

A collapsible group that holds settings rows.

VerifiedSince 0.3.4

Usage

Basic

TxGroupBlock holds a set of settings rows; clicking the header expands or collapses it.

Loading demo...

Initially Collapsed

:default-expand="false" collapses the group on first render.

Loading demo...

Remembered State

With memory-name set, the expanded state survives a reload.

Loading demo...

Header Actions

The header-extra slot sits before the collapse chevron.

Loading demo...

Read-Only Rows

TxBlockLine shows a title and value side by side; when they don't fit, the value wraps below the title.

Loading demo...

link renders the row as a button that emits click; put its content in the description slot.

Loading demo...

Custom Controls

The default slot of TxBlockSlot takes any control.

Loading demo...

Active State and Tags

active swaps in activeIcon; the tags slot sits beside the title.

Loading demo...

Custom Labels

The label slot replaces the title and description.

Loading demo...

Input Rows

TxBlockInput is a settings row with a built-in TxInput.

Loading demo...

Select Rows

TxBlockSelect is a settings row with a built-in TxSelect; options go in the default slot.

Loading demo...

Switch Rows

Loading demo...

Switch Loading

loading turns the inner switch's thumb into a spinning ring and freezes the row without dimming it.

Loading demo...

Switch Disabled

Loading demo...

Guidance Rows

guidance replaces the switch with a chevron and emits only click.

Loading demo...

Best Practices

  • Keep each memoryName unique and stable; don't share a key between unrelated groups.
  • Set collapsible=false on always-visible status or form sections so they don't imply hidden content.
  • Use TxBlockLine for read-only values and light navigation, TxBlockSlot for custom controls, TxBlockInput / TxBlockSelect for standard form rows, and TxBlockSwitch for booleans and navigation.
  • Keep row titles short and move long explanations into the description; don't nest complex layouts in a row.
  • The group squares off its rows; don't hard-code border-radius: 0 on a row to imitate that look.

API Reference

TxGroupBlock

Props

PropTypeDefaultDescription
namestringrequiredGroup title.
descriptionstring''Text below the title.
defaultIconTxIconSource | string-Icon while collapsed; also the fallback for activeIcon.
activeIconTxIconSource | string-Icon while expanded; falls back to defaultIcon.
iconSizenumber22Header icon size in px.
collapsiblebooleantrueLets the header expand and collapse the group.
collapsedbooleanfalseExternal collapsed state, re-applied on change until the user toggles or a stored state exists.
defaultExpandboolean-Expanded state on first render; wins over collapsed, and defaults to !collapsed.
memoryNamestring''Persists the expanded state in localStorage under the tuff-block-storage- prefix.

Events

EventParamsDescription
update:expandedexpanded: booleanFires after the user toggles the group.
toggleexpanded: booleanFires together with update:expanded.

Slots

SlotPropsDescription
default-Rows inside the group.
icon{ active: boolean }Custom header icon.
header-extra{ active: boolean }Header actions, before the collapse chevron.

TxBlockLine

Props

PropTypeDefaultDescription
titlestring''Row title.
descriptionstring''Value of a non-link row; the description slot replaces it.
linkbooleanfalseRenders a native button with link styling that emits click.

Events

EventParamsDescription
clickevent: MouseEventFires only when link is set.

Slots

SlotPropsDescription
description-Custom value or link content.

TxBlockSlot

Props

PropTypeDefaultDescription
titlestring''Title; not rendered when the label slot is used.
descriptionstring''Description; not rendered when the label slot is used.
defaultIconTxIconSource | string-Icon while inactive; also the fallback for activeIcon.
activeIconTxIconSource | string-Icon while active; falls back to defaultIcon.
iconSizenumber20Icon size in px.
activebooleanfalseSwaps in activeIcon and passes active to slot scopes; doesn't restyle the row.
disabledbooleanfalseDisabled styling; blocks click.

Events

EventParamsDescription
clickevent: MouseEventFires on row click; once bound, the row is focusable and also fires on Enter / Space.

Slots

SlotPropsDescription
default{ active: boolean }Control area on the right.
icon{ active: boolean }Custom icon.
label-Replaces the title and description.
tags-Metadata beside the title, or below a custom label.

TxBlockInput

Props

PropTypeDefaultDescription
modelValuestring | number''Input value, bound with v-model.
titlestring''Row title.
descriptionstring''Row description.
defaultIconTxIconSource | string-Icon while unfocused; also the fallback for activeIcon.
activeIconTxIconSource | string-Icon while focused.
disabledbooleanfalseDisables the row and the input.
placeholderstring''Placeholder text.
clearablebooleanfalseForwarded to TxInput.
inputType'text' | 'password' | 'number' | 'email''text'Forwarded as the TxInput type.

Events

EventParamsDescription
update:modelValuevalue: string | numberFires when the input value changes.
inputvalue: string | numberMirrors the TxInput input event.
focusevent: FocusEventFires when the input gains focus.
blurevent: FocusEventFires when the input loses focus.

Slots

SlotPropsDescription
control{ value: string | number, focused: boolean }Replaces the default TxInput.
tags-Metadata beside the title.

TxBlockSelect

Props

PropTypeDefaultDescription
modelValuestring | number''Selected value, bound with v-model.
titlestring''Row title.
descriptionstring''Row description.
defaultIconTxIconSource | string-Icon with no value selected; also the fallback for activeIcon.
activeIconTxIconSource | string-Icon with a value selected.
disabledbooleanfalseDisables the row and the select.
placeholderstring''Placeholder text.

Events

EventParamsDescription
update:modelValuevalue: string | numberFires when the selected value changes.
changevalue: string | numberFires together with update:modelValue.

Slots

SlotPropsDescription
default-TxSelect options such as TuffSelectItem.
tags-Metadata beside the title.

TxBlockSwitch

Props

PropTypeDefaultDescription
modelValuebooleanrequiredSwitch value, bound with v-model.
titlestringrequiredRow title.
descriptionstringrequiredRow description.
defaultIconTxIconSource | string-Icon while off; also the fallback for activeIcon.
activeIconTxIconSource | string-Icon while on; falls back to defaultIcon.
disabledbooleanfalseDisables the row and the switch.
guidancebooleanfalseShows a chevron instead of the switch, as a navigation row.
loadingbooleanfalseForwarded to the inner switch: the thumb spins, the row shimmers, and interaction pauses.

Events

EventParamsDescription
update:modelValuevalue: booleanFires when the switch value changes.
changevalue: booleanMirrors the switch change after a user toggle.
clickevent: MouseEventFires only in guidance mode.

Slots

SlotPropsDescription
tags-Metadata beside the title.

Overview

  • The first-render state comes from the stored state, then defaultExpand, then !collapsed; after the user toggles, prop changes no longer override it.
  • The group body stays mounted; collapsing only changes height, opacity, and display.
  • The group resets each row's --fake-radius and margin so only the group card is rounded; a standalone row keeps its 12px radius.
  • TxBlockLine is a non-interactive div unless link is set, when it becomes a <button type="button">.
  • TxBlockSlot never shrinks its control area; TxBlockInput is the exception, letting its field shrink to 120px to make room for the title.
  • In TxBlockSwitch, the busy cue lives only on the inner switch (is-loading + aria-busy) and the row only shimmers; guidance mode never writes modelValue.

Technologies

  • GSAP animates height and opacity on expand and collapse, then releases to auto or display: none.
  • Source: packages/tuffex/packages/components/src/group-block/.
查看源码
packages/tuffex/packages/components/src/group-block/index.ts

Customization

Theme tokenUsed for
--tx-border-color-lighterGroup border and header divider.
--tx-fill-color-dark / --tx-fill-color / --tx-fill-color-lightHeader, row, and hover surfaces.
--tx-text-color-primary / --tx-text-color-secondaryTitles, labels, descriptions, guidance arrows, and the loading ring.
--tx-color-primary / --tx-color-primary-dark-2Link-row text and hover colors.
--tx-color-whiteLoading shimmer highlight.