@@ -42,6 +42,11 @@ export interface IButtonAttrs extends ComponentAttrs {
4242 * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-type
4343 */
4444 type ?: string ;
45+ /**
46+ * Helper text. Displayed under the button label.
47+ *
48+ * Default: `null`
49+ */
4550}
4651
4752/**
@@ -56,7 +61,7 @@ export interface IButtonAttrs extends ComponentAttrs {
5661 */
5762export default class Button < CustomAttrs extends IButtonAttrs = IButtonAttrs > extends Component < CustomAttrs > {
5863 view ( vnode : Mithril . VnodeDOM < CustomAttrs , this> ) {
59- let { type, 'aria-label' : ariaLabel , icon : iconName , disabled, loading, className, class : _class , ...attrs } = this . attrs ;
64+ let { type, 'aria-label' : ariaLabel , icon : iconName , disabled, loading, className, class : _class , helperText , ...attrs } = this . attrs ;
6065
6166 // If no `type` attr provided, set to "button"
6267 type ||= 'button' ;
@@ -108,8 +113,17 @@ export default class Button<CustomAttrs extends IButtonAttrs = IButtonAttrs> ext
108113
109114 return [
110115 iconName && < Icon name = { iconName } className = "Button-icon" /> ,
111- children && < span className = "Button-label" > { children } </ span > ,
116+ children && (
117+ < span className = "Button-label" >
118+ < span className = "Button-labelText" > { children } </ span >
119+ { this . getButtonSubContent ( ) }
120+ </ span >
121+ ) ,
112122 this . attrs . loading && < LoadingIndicator size = "small" display = "inline" /> ,
113123 ] ;
114124 }
125+
126+ protected getButtonSubContent ( ) : Mithril . Children {
127+ return this . attrs . helperText ? < span className = "Button-helperText" > { this . attrs . helperText } </ span > : null ;
128+ }
115129}
0 commit comments