Form Actions
<zn-form-actions>
ZnFormActions
Drops the standard action row into a form. The default is just a primary submit button — build it up with
with-cancel and with-reset as the form needs. Place it inside the form it should
act on.
<form> <zn-form-actions></zn-form-actions> </form>
Examples
With a Cancel Button
Use the with-cancel attribute to add a cancel button. When the form lives inside a dialog or
slideout, cancelling closes it; it also emits a zn-cancel event for the container to handle.
<zn-dialog trigger="form-actions-dialog" label="New Ticket"> <form> <zn-form-actions with-cancel></zn-form-actions> </form> </zn-dialog> <zn-button id="form-actions-dialog">Open Dialog</zn-button>
With a Reset Button
Use the with-reset attribute to add a button that resets the form’s fields.
<form> <input type="text" name="example" value="Change me, then reset"> <zn-form-actions with-reset></zn-form-actions> </form>
Hide Until Changed
Use the hide-until-changed attribute to keep the row hidden until a field in the form changes.
It hides again once the form is back to its original values — undone by hand, reset, or saved.
<form> <zn-input name="title" label="Title" value="Edit me"></zn-input> <zn-form-actions hide-until-changed with-reset></zn-form-actions> </form>
Custom Text and Icons
Each button’s text and icon can be overridden with submit-text / submit-icon,
cancel-text / cancel-icon and reset-text / reset-icon.
<form> <zn-form-actions with-cancel submit-text="Create Ticket" submit-icon="plus@lu" cancel-text="Discard" cancel-icon="trash-2@lu"></zn-form-actions> </form>
Extra Actions
Extra buttons placed in the default slot appear before the standard buttons.
<form> <zn-form-actions> <zn-button color="transparent">Preview</zn-button> </zn-form-actions> </form>
Start-Aligned Actions
align="start" on a slotted child moves it to the start of the row; any number can sit on either
side. Write the buttons in the order they should be read — the sides are set by CSS ordering, so markup
order is what a keyboard follows.
<form> <zn-form-actions with-cancel> <zn-button align="start" color="transparent" icon="languages@lu">Translate Missing</zn-button> <zn-button align="start" color="transparent" icon="refresh-cw@lu">Regenerate Slug</zn-button> </zn-form-actions> </form>
Targeting a Form by Id
When the component can’t live inside the form, point it at one with the form attribute.
<form id="standalone-form"></form> <zn-form-actions form="standalone-form"></zn-form-actions>
Importing
If you’re using the autoloader or the traditional loader, you can ignore this section. Otherwise, feel free to use any of the following snippets to cherry pick this component.
To import this component from the CDN using a script tag:
<script type="module" src="https://cdn.jsdelivr.net/npm/@kubex/zinc@2.0.55/dist/components/form-actions/form-actions.js"></script>
To import this component from the CDN using a JavaScript import:
import 'https://cdn.jsdelivr.net/npm/@kubex/zinc@2.0.55/dist/components/form-actions/form-actions.js';
To import this component using a bundler:
import '@kubex/zinc/dist/components/form-actions/form-actions.js';
Properties
| Name | Description | Reflects | Type | Default |
|---|---|---|---|---|
submitText
submit-text
|
The submit button’s text. |
string
|
'Save'
|
|
submitIcon
submit-icon
|
The submit button’s icon. |
string
|
'check@lu'
|
|
withCancel
with-cancel
|
Adds a cancel button. Closes the containing dialog or slideout, if any, and emits
zn-cancel.
|
boolean
|
false
|
|
cancelText
cancel-text
|
The cancel button’s text. |
string
|
'Cancel'
|
|
cancelIcon
cancel-icon
|
The cancel button’s icon. |
string
|
'x@lu'
|
|
withReset
with-reset
|
Adds a reset button that resets the form. |
boolean
|
false
|
|
resetText
reset-text
|
The reset button’s text. |
string
|
'Reset'
|
|
resetIcon
reset-icon
|
The reset button’s icon. |
string
|
'rotate-ccw@lu'
|
|
align
|
Which side the buttons sit on. start puts them on the left with submit first, as on a
search panel, and moves extra content without its own align to the right.
|
|
'start' | 'end'
|
'end'
|
form
|
The id of the form to act on. If omitted, the closest containing form is used. |
string
|
- | |
loadingOnSubmit
loading-on-submit
|
Shows the submit button loading and ignores further submits until the console reports the request finished, so a slow save such as an upload can’t be sent twice. Only for forms the console submits. |
boolean
|
false
|
|
hideUntilChanged
hide-until-changed
|
Hides the row until the form’s values differ from when it loaded or was last saved, and hides it again once they match. |
|
boolean
|
false
|
updateComplete |
A read-only promise that resolves when the component has finished updating. |
Learn more about attributes and properties.
Methods
| Name | Description | Arguments |
|---|---|---|
setLoading() |
Shows the submit button loading while a filter wrapper fetches its results. |
loading: boolean
|
Learn more about methods.