# More ui-bind commands: attributes, values, state and formatting

> Set HTML, attributes, form values, disabled state and a text format from the state with ui-bind commands.

Framework: jcomponent20
Product: jComponent 20 (jcomponent@20)
Language: en
Content-SHA256: d2eab2bb102a37f53d6827705cb5c632ede7dd263e6cc9a51ba6b2b0ba931523
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: jcomponent20@3fedd009a277f50fddc608b97afbec553b67c51b
Review: not-recorded

Besides `text`, `show` and `hide`, `ui-bind` has commands for the common DOM changes. Each command is `name:expression` (or `name selector:expression` to apply it to an inner element), and `value` is the value of the path:

| Command | Does |
|---|---|
| `html:expr` | sets the inner HTML (escape it yourself!) |
| `title:expr`, `href:expr`, `src:expr` | sets that attribute |
| `attr name:expr` | sets any attribute |
| `value:expr` | sets the value of a form control |
| `disabled:expr` / `enabled:expr` | disables or enables the controls inside |
| `checked:expr` | checks the checkbox inside |
| `.class:expr` | adds or removes the class |

Options of the whole element: `format:yyyy-MM-dd` formats a date value before it is printed (for numbers call `format()` in the expression: `text:value.format(2)`), `empty:none` is shown when the value is empty, `changes` skips updates when the value did not change, and `delay:200` waits that many milliseconds before rendering.

```html public/index.html
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
	<title>jComponent</title>
	<link rel="stylesheet" href="//cdn.componentator.com/spa.min@20.css" />
	<script src="//cdn.componentator.com/spa.min@20.js"></script>
</head>
<body>
	<ui-bind path="user" config="attr data-id:value.id;title:value.name;text:value.name" class="greeting"></ui-bind>
	<ui-bind path="product.price" config="text:value.format(2)" class="price"></ui-bind>
	<ui-bind path="product.date" config="text:value;format:yyyy-MM-dd" class="date"></ui-bind>
	<ui-bind path="user.admin" config="disabled:!value"><button type="button" id="delete">Delete</button></ui-bind>
	<ui-bind path="user.nick" config="value input:value;empty:anonymous"><input type="text" /></ui-bind>
	<ui-bind path="user.nick" config="text:value;empty:anonymous" class="nick"></ui-bind>

	<script>
		SET('user', { id: 7, name: 'Peter', admin: false, nick: '' });
		SET('product', { price: 1234.5, date: new Date(2026, 9, 16) });
	</script>

</body>
</html>
```
