* The `oh-button` component is based upon the [Framework 7 Vue button control (`f7-button`)](https://v5.framework7.io/vue/button.html).
* Component styles are applied by the [Framework 7 CSS variables](https://v5.framework7.io/docs/button.html#css-variables). For guidance on how to customise styles see the [CSS Styles](https://openhab.org/docs/ui/building-pages.html#css-variables) section.
* Use the [`f7-segmented`](#f7-segmented) wrapper component to group buttons together. Buttons with the property `active: true` set will be highlighted/marked as selected.
Consider the variable value is an object and set the corresponding deep property within that object using a key syntax. Examples: <code>user.name</code>, <code>user[0].address[1].street</code>, <code>[0]</code>, <code>[0].label</code>. The inner property and its parent hierarchy will be created if missing.
<PropBlocktype="BOOLEAN"name="clearVariableKey"label="Clear Object Variable Property After Action">
<PropDescription>
Consider the variable value is an object and remove a corresponding deep property within that object using a key syntax. Examples: <code>user.name</code>, <code>user[0].address[1].street</code>, <code>[0]</code>, <code>[0].label</code>. The property will be removed after performing the action.
Comma-separated list of options; if omitted, retrieve the command options from the Item dynamically. Use <code>value=label</code> format to provide a label different than the option.
Object representing the optional context to pass. Edit in YAML or provide a JSON object, e.g. <code>{ "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }</code>.
Use a specific <aclass="external text-color-blue"target="_blank"href="https://framework7.io/docs/view.html#custom-page-transitions">page transition animation</a>
</PropDescription>
<PropOptions>
<PropOptionvalue="f7-circle"label="Circle"/>
<PropOptionvalue="f7-cover"label="Cover"/>
<PropOptionvalue="f7-cover-v"label="Cover from bottom"/>
<PropOptionvalue="f7-dive"label="Dive"/>
<PropOptionvalue="f7-fade"label="Fade"/>
<PropOptionvalue="f7-flip"label="Flip"/>
<PropOptionvalue="f7-parallax"label="Parallax"/>
<PropOptionvalue="f7-push"label="Push"/>
</PropOptions>
</PropBlock>
<PropBlocktype="TEXT"name="actionModal"label="Modal Page or Widget"context="pagewidget">
Array of URLs or objects representing the images. Auto-refresh is not supported.<br/>Edit in YAML, e.g.<br/><code><pre>- item: ImageItem1<br/> caption: Camera</pre></code>or provide a JSON array, e.g.<br/><code>[ "url1", { "item": "ImageItem1", "caption": "Camera" } ]</code><br/>Objects are in the <aclass="external text-color-blue"target="_blank"href="https://framework7.io/docs/photo-browser.html#photos-array">photos array format</a> with an additional <code>item</code> property to specify an item to view.
Configuration for the photo browser.<br/>Edit in YAML or provide a JSON object, e.g.<br/><code>{ "exposition": false, "type": "popup", "theme": "dark" }</code><br/> See <aclass="external text-color-blue"target="_blank"href="https://framework7.io/docs/photo-browser.html#photo-browser-parameters">photo browser parameters</a> (not all are supported).
Shows a dialog or sheet to ask for confirmation before the action is executed. Can either be a text to show in the dialog or a JSON object <code>{ type: "dialog", title: "Confirm", text: "Are you sure?" }</code> or <code>{ type: "sheet", text: "Confirm", color: "green" }</code>
Shows a toast popup when the action has been executed. Can either be a text to show or a JSON object including some of the <aclass="external text-color-blue"target="_blank"href="https://framework7.io/docs/toast.html#toast-parameters">supported parameters</a>
Consider the variable value is an object and set the corresponding deep property within that object using a key syntax. Examples: <code>user.name</code>, <code>user[0].address[1].street</code>, <code>[0]</code>, <code>[0].label</code>. The inner property and its parent hierarchy will be created if missing.
Comma-separated list of options; if omitted, retrieve the command options from the Item dynamically. Use <code>value=label</code> format to provide a label different than the option.
Object representing the optional context to pass. Edit in YAML or provide a JSON object, e.g. <code>{ "param1": "value1", "param2": { "subkey1": "testing", "subkey2": 123 } }</code>.
Use a specific <aclass="external text-color-blue"target="_blank"href="https://framework7.io/docs/view.html#custom-page-transitions">page transition animation</a>
</PropDescription>
<PropOptions>
<PropOptionvalue="f7-circle"label="Circle"/>
<PropOptionvalue="f7-cover"label="Cover"/>
<PropOptionvalue="f7-cover-v"label="Cover from bottom"/>
<PropOptionvalue="f7-dive"label="Dive"/>
<PropOptionvalue="f7-fade"label="Fade"/>
<PropOptionvalue="f7-flip"label="Flip"/>
<PropOptionvalue="f7-parallax"label="Parallax"/>
<PropOptionvalue="f7-push"label="Push"/>
</PropOptions>
</PropBlock>
<PropBlocktype="TEXT"name="taphold_actionModal"label="Modal Page or Widget"context="pagewidget">
Array of URLs or objects representing the images. Auto-refresh is not supported.<br/>Edit in YAML, e.g.<br/><code><pre>- item: ImageItem1<br/> caption: Camera</pre></code>or provide a JSON array, e.g.<br/><code>[ "url1", { "item": "ImageItem1", "caption": "Camera" } ]</code><br/>Objects are in the <aclass="external text-color-blue"target="_blank"href="https://framework7.io/docs/photo-browser.html#photos-array">photos array format</a> with an additional <code>item</code> property to specify an item to view.
Configuration for the photo browser.<br/>Edit in YAML or provide a JSON object, e.g.<br/><code>{ "exposition": false, "type": "popup", "theme": "dark" }</code><br/> See <aclass="external text-color-blue"target="_blank"href="https://framework7.io/docs/photo-browser.html#photo-browser-parameters">photo browser parameters</a> (not all are supported).
Shows a dialog or sheet to ask for confirmation before the action is executed. Can either be a text to show in the dialog or a JSON object <code>{ type: "dialog", title: "Confirm", text: "Are you sure?" }</code> or <code>{ type: "sheet", text: "Confirm", color: "green" }</code>
Shows a toast popup when the action has been executed. Can either be a text to show or a JSON object including some of the <aclass="external text-color-blue"target="_blank"href="https://framework7.io/docs/toast.html#toast-parameters">supported parameters</a>
Consider the variable value is an object and set the corresponding deep property within that object using a key syntax. Examples: <code>user.name</code>, <code>user[0].address[1].street</code>, <code>[0]</code>, <code>[0].label</code>. The inner property and its parent hierarchy will be created if missing.
The configuration is passed to the underlying `f7-button` component from Framework7 v5.
All compatible scalar [properties](https://v5.framework7.io/vue/button.html#button-properties) (except functions) not listed above are available for use.
### Slots
#### `default`
The contents of the button.
## Examples
### Header Image Source Code
This example code generates the button image used at the top of this page:
::: details YAML
```yaml
uid: oh-button
tags: []
timestamp: Feb 9, 2021, 5:42:56 PM
component: f7-card
config:
title: oh-button
slots:
default:
- component: f7-block
config:
class: bog
style:
display: flex
flex-wrap: wrap
justify-content: space-between
align-content: space-between
height: 230px
padding-bottom: 20px
slots:
default:
- component: oh-button
config:
width: 400px
text: Basic button
- component: oh-button
config:
width: 400px
text: Rounded + Outline
round: true
outline: true
- component: oh-button
config:
text: Large
outline: true
large: true
grid-colum: 3
grid-row: 1
- component: oh-button
config:
text: Small + Outline
outline: true
small: true
- component: oh-button
config:
text: Filled
fill: true
- component: oh-button
config:
text: Raised
fill: true
raised: true
- component: oh-button
config:
text: Outline
outline: true
- component: oh-button
config:
text: f7 icon
iconF7: arrow_right_arrow_left_square_fill
tooltip: Click to view f7 icons
action: url
actionUrl: https://framework7.io/icons/
- component: oh-button
config:
text: Material icon
iconMaterial: fingerprint
tooltip: Click to view Material icons
action: url
actionUrl: https://material.io/resources/icons/
- component: oh-button
config:
text: Icon color
iconMaterial: power_settings_new
iconColor: green
- component: oh-button
config:
text: 40px icon, with custom button height to fit it!
`action: toggle` is used to change any item that supports two states e.g. a lamp that is either ON or OFF or blinds that are OPEN or CLOSED.
Use `actionCommand` and `actionCommandAlt` to specify the commands to switch between.
If you need the item to change to more than two states e.g. a dimmable light, see the [previous example](#action-command) and specify a button for each of the dimming levels required e.g. 0%, 25%, 50% 75%, 100% or use [`actionOptions`](#action-options) to select the required option.
::: details YAML
``` yaml{37-40}
uid: oh-button-action-toggle
tags: []
props:
parameters:
- context: item
description: Select the item to use with these buttons.
label: Item
name: item
required: true
type: TEXT
groupName: general
parameterGroups:
- name: general
label: Display options
timestamp: Feb 15, 2021, 9:55:56 PM
component: f7-card
config:
title: "oh-button > action: toggle"
footer: Set the properties to any item that accepts an ON/OFF commands
slots:
default:
- component: f7-block
config:
class: bog
style:
display: flex
flex-wrap: wrap
justify-content: space-between
align-content: space-between
padding: 20px
slots:
default:
- component: oh-button
config:
text: Off
outline: true
action: toggle
actionItem: =props.item
actionCommand: ON
actionCommandAlt: OFF
style:
width: 100px
```
:::
### action: options
<!-- BOOKMARKS to this exam<<< @/filepath{highlightLines}ple -->
`action: options` provides the ability to send a command from a list of options. Options are displayed at the bottom of the screen when the button is clicked. Options are specified either in the `actionOptions` property or if this is omitted from the `Command Options` metadata specified on the item.
::: details YAML
``` yaml
uid: oh-button-action-options
tags: []
props:
parameters:
- context: item
description: Select the item to use with these buttons.
label: Item
name: item
required: true
type: TEXT
groupName: general
parameterGroups:
- name: general
label: Display options
timestamp: Feb 15, 2021, 11:57:34 PM
component: f7-card
config:
title: "oh-button > action: options"
footer: Set the properties to any item that accepts percentage commands e.g. dimmable light
The popup, popover and sheet actions provide a way to display user interface pages in specific window formats.
Typically these screens are used to display additional detail or access additional settings that have been omitted for brevity from the parent page.
Pages should normally be specifically designed for your chosen display method.
The popover area favours organisation of widgets in columns, but the sheet window occupies the full width of the lower part of the screen and therefore a horizontal layout is preferable.
The example code simply displays a copy of your main 'Overview' page (as all users have this page) in each window style.
As this page is rarely designed with this purpose in mind the design challenge is usually clear!
*`action: popup` is used with the `actionModal` property to open a page as a modal popup window in the centre of the screen.
Clicking on the `Back` button or anywhere else on the screen will close the popup window.
*`action: popover` is used with the `actionModal` property to open a page as a modal popup window as a vertical rectangle to the left of the screen (over the menu area, if displayed).
*`action: sheet` is used with the `actionModal` property to open a page as a modal popup windows as a horizontal rectangle across the bottom of the screen.
`action: url` navigates to the web page specified in the `actionUrl` property. `actionUrlSameWindow` set to `true` to open in the same window, or `false` to open in a seperate window\tab.
`action: variable` creates and/or sets the variable specified in `actionVariable` to the value specified in `actionVariableValue`. Variables are stored in the `vars` object and can be accessed by other objects using `vars.[your variable name]`.
[UI Widget: Keypad](https://community.openhab.org/t/ui-widget-keypad/106820) - using `action: command` and `action: variable`, this widget will allow users to enter a numerical PIN code (plus * and #) and send a command with the result to a predefined item when pressing the Send button.
![Big Ol' Grid O' Buttons](./images/oh-button/bogob.png)
[BoGoB: Big Ol' Grid O' Buttons](https://community.openhab.org/t/bogob-big-ol-grid-o-buttons-is-this-even-possible-yes-yes-it-is/115343/7) - using the `oh-button` and `oh-repeater` objects together with YAML arrays to create large grids of buttons (emulating remote control operation).