dynamic-forms / Function

buildClassName

Builds a combined className string from a field definition.

Combines user-provided className with generated grid classes into a single string. Returns undefined if no classes are present (allowing conditional spreading in objects).

Presentation

function buildClassName(
  fieldDef: FieldDef<unknown, FieldMeta>,
): string | undefined;

Returns

string | undefined -

Combined class string, or undefined if no classes

Parameters

NameTypeDescription
fieldDef
FieldDef<unknown, FieldMeta>

Field definition containing className and col properties

Example usage

// With both className and col
buildClassName({ key: 'test', type: 'group', className: 'my-class', col: 6 });
// Returns: 'df-col-6 my-class'

// With only className
buildClassName({ key: 'test', type: 'group', className: 'my-class' });
// Returns: 'my-class'

// With only col
buildClassName({ key: 'test', type: 'group', col: 6 });
// Returns: 'df-col-6'

// With neither
buildClassName({ key: 'test', type: 'group' });
// Returns: undefined