Components/FineTuneCard

FineTuneCard

A compact property inspector over one value object.

VerifiedSince 0.3.9

Usage

Basic

All six fields travel in one values object; once it differs from defaults, the header flips to Edited and changed fields are tinted.

Loading demo...

Best Practices

  • Pass the loaded preset's initial values as defaults, not a constant, and swap them with the preset.
  • Use change for the undo stack and update:values for state; both fire, so don't do the work twice in one handler.
  • Give ranges the real constraints (a radius no larger than half the short side) and let clamping block invalid values.
  • The inspector is narrow (240px), so abbreviate captions; fieldLabels replaces the whole set for localization.
  • On non-English surfaces, pass layoutLabels: the three layout options are glyph-only, so these names are all a screen reader announces.
  • Each value input's aria-label is built from its caption by valueLabelFormatter; on non-English surfaces pass one too, or it reads as " value".

API Reference

Props

NameTypeDefaultDescription
valuesFineTuneValues—The six-field value object, controlled.
defaultsPartial<FineTuneValues>—Baseline for the header state and per-field tinting.
editedboolean—Forces the header state, ignoring defaults.
titlestring'Fine-tune'Card title.
layoutLabel / typeLabelstring'Layout' / 'Type'Section headings.
layoutLabelsPartial<Record<FineTuneLayout, string>>row layout / col layout / grid layoutAccessible names of the three layout options.
typeOptionsFineTuneTypeOption[][]Type options, { value, label }.
typePlaceholderstring'Select type'Shown until a type is picked.
adjustLabel / editedLabelstring'Adjust' / 'Edited'The header's two states.
fieldLabelsPartial<Record<FineTuneField, string>>W / H / Radius / OpacityCaptions for the four numeric fields.
valueLabelFormatter(label: string) => string(label) => `${label} value`Builds each value input's aria-label from its caption.
rangesPartial<Record<FineTuneField, FineTuneRange>>see belowPer-field bounds.
disabledbooleanfalseDisables every control at once.

Default ranges: width 40–999, height 24–999, radius 0–64, opacity 0–100.

Events

EventPayloadDescription
update:values(values: FineTuneValues)Fires on any edit with the whole new object.
change(key, value)Fires with update:values, naming the key that moved and its new value.

Overview

  • The layout segment reuses TxFlatRadio: a real radiogroup, arrow keys move between options, and the group is one tab stop.
  • The four numeric fields are TxScrubField: the caption is the handle, and values can be dragged, stepped with the keyboard, or typed.
  • The type picker opens upward as a combobox with a listbox: arrow keys rove from the current selection, Home / End, Enter or Space commits, Escape closes and restores focus, and outside clicks or focus-out close it.
  • Nothing is emitted when a value would not change; disabled reaches the segment, the fields, and the picker.
  • Under reduced motion the Adjust shimmer stops and the label returns to solid text.

Technologies

  • The type picker, TxFineTuneChipSelect, is internal and not exported.
  • Adapted from Beautiful UI (© 2026 Shane Levine, MIT).
  • Source: packages/tuffex/packages/components/src/fine-tune-card/.
查看源码
packages/tuffex/packages/components/src/fine-tune-card/index.ts