Takes an object and "spreads" it as html attributes similar to what JSX does.

Parameters:
NameTypeDescription
propsobject

The object to spread.

Since
  • 1.2.15
Returns:

The html attributes.

Type: 
string
Example
import { objectToAttributes } from "@gravityforms/utils";

function Example() {
  const customAttributes = {
     'placeholder': 'placeholder text',
     'name': 'idForThing',
  },
	 const customClasses = [
	    'class-one',
	    'class-two',
	 ],
  const props = {
		class: [
			'class-required',
			...customClasses,
		],
		id: 'idForThing',
		...customAttributes,
  };
  objectToAttributes( props );
}