diff --git a/source/_patterns/01-elements/buttons/10-button-width.hbs b/source/_patterns/01-elements/buttons/10-button-width.hbs new file mode 100644 index 00000000000..8b1f2e2b801 --- /dev/null +++ b/source/_patterns/01-elements/buttons/10-button-width.hbs @@ -0,0 +1,6 @@ +{{!-- TODO: let's not use those modifier classes, but inherit their meaning via CSS correctly and introduce sample classes for the styleguide --}} +
+ {{> elements-button variant='brand-primary' value='(Default) Auto width'}} + + {{> elements-button variant='brand-primary' value='Width full' width='full' }} +
diff --git a/source/_patterns/01-elements/buttons/_buttons.md b/source/_patterns/01-elements/buttons/_buttons.md index 89cced3a1c1..7cd9c13be85 100644 --- a/source/_patterns/01-elements/buttons/_buttons.md +++ b/source/_patterns/01-elements/buttons/_buttons.md @@ -25,6 +25,18 @@ Extend one of the size SCSS placeholders in case that you don't want the default You could set the different button sizes via the `data-size` attribute, the default is "regular" and in that case is optional. +### Width + +Regularly, our buttons shouldn't increase to it's horizontally available space, but only the one determined by it's included textual content. + +#### SCSS (recommended) + +Extend the width SCSS placeholders in case that you don't want the default (`auto`): `%width-Full` + +#### HTML attribute + +You could set the button width to increase to it's full available space via the `data-width="full"` attribute, the default is `auto` and in that case is optional. + ## Usability > Buttons should be used in situations where users might need to: diff --git a/source/_patterns/01-elements/buttons/button.hbs b/source/_patterns/01-elements/buttons/button.hbs index 4e8f0b8e7ef..50a40b920b4 100644 --- a/source/_patterns/01-elements/buttons/button.hbs +++ b/source/_patterns/01-elements/buttons/button.hbs @@ -7,6 +7,7 @@ {{#if disabled }} disabled{{/if }} {{#if icon}} data-icon="{{ icon }}"{{/if}} {{#if icon-after}} data-icon-after="{{ icon-after }}"{{/if}} - {{#if label}} aria-label="{{ label }}"{{/if }}> + {{#if label}} aria-label="{{ label }}"{{/if }} + {{#if width }} data-width="{{ width }}"{{/if }}> {{{ value }}} diff --git a/source/_patterns/01-elements/buttons/button.scss b/source/_patterns/01-elements/buttons/button.scss index 42f833cdf61..ac2b83ade46 100644 --- a/source/_patterns/01-elements/buttons/button.scss +++ b/source/_patterns/01-elements/buttons/button.scss @@ -216,4 +216,13 @@ &:disabled { color: unquote($button---color + "80"); } + + // width + &%width-Full { + inline-size: 100%; + } + + &[data-width="full"] { + @extend %width-Full; + } }