# Show, hide and style elements with ui-bind

> Use ui-bind commands to toggle visibility, classes and HTML from the state, without writing DOM code.

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

`<ui-bind path="..." config="...">` applies **commands** to its element whenever the value of the path changes. Commands are separated by semicolons. Each command is `name:expression`, where `value` is the current value of the path:

- `show:value` / `hide:value` shows or hides the element
- `html:value` / `text:value` replaces the content
- `.classname:value` adds the class when the expression is truthy

```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>
	<style>.hidden { display: none; } .admin { color: crimson; }</style>
</head>
<body>

	<ui-bind path="user.admin" config="show:value" class="hidden">Admin panel</ui-bind>
	<ui-bind path="user.admin" config="hide:value">You are a guest</ui-bind>
	<ui-bind path="user.name" config=".admin:value === 'Peter';text:value">-</ui-bind>

	<script>
		SET('user.admin', false);
		SET('user.name', 'Louis');
	</script>

</body>
</html>
```
