Skip to content

Commit 5ae977d

Browse files
committed
buttons in actions() support color
1 parent 5b9ec84 commit 5ae977d

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

docs/spec.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ Unique attributes of different input types:
138138

139139
* actions
140140

141-
* buttons: ``{label:, value:, [type: 'submit'/'reset'/'cancel'], [disabled:]}`` .
141+
* buttons: ``{label:, value:, [type: 'submit'/'reset'/'cancel'], [disabled:], [color:]}`` .
142142

143143

144144
* file:

pywebio/input.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,8 @@ def actions(label='', buttons=None, name=None, help_text=None):
464464
"label":(str) button label,
465465
"value":(object) button value,
466466
"type":(str, optional) button type,
467-
"disabled":(bool, optional) whether the button is disabled
467+
"disabled":(bool, optional) whether the button is disabled,
468+
"color":(str, optional) button color
468469
}
469470
470471
When ``type='reset'/'cancel'`` or ``disabled=True``, ``value`` can be omitted
@@ -485,6 +486,9 @@ def actions(label='', buttons=None, name=None, help_text=None):
485486
Note: After clicking the ``type=reset`` button, the form will not be submitted,
486487
and the ``actions()`` call will not return
487488
489+
The ``color`` of button can be one of: `primary`, `secondary`, `success`, `danger`, `warning`, `info`, `light`,
490+
`dark`.
491+
488492
:param - label, name, help_text: Those arguments have the same meaning as for `input()`
489493
:return: If the user clicks the ``type=submit`` button to submit the form,
490494
return the value of the button clicked by the user.
@@ -525,8 +529,8 @@ def actions(label='', buttons=None, name=None, help_text=None):
525529
actions('actions', [
526530
{'label': 'Save', 'value': 'save'},
527531
{'label': 'Save and add next', 'value': 'save_and_continue'},
528-
{'label': 'Reset', 'type': 'reset'},
529-
{'label': 'Cancel', 'type': 'cancel'},
532+
{'label': 'Reset', 'type': 'reset', 'color': 'warning'},
533+
{'label': 'Cancel', 'type': 'cancel', 'color': 'danger'},
530534
], name='action', help_text='actions'),
531535
])
532536
put_code('info = ' + json.dumps(info, indent=4))

0 commit comments

Comments
 (0)