diff --git a/packages/button/README.md b/packages/button/README.md index dc6a49d9e..2ae15d2e3 100644 --- a/packages/button/README.md +++ b/packages/button/README.md @@ -6,6 +6,7 @@ 1. [Button circle](#button-circle) 1. [Button with left icon](#button-with-left-icon) 1. [Button with right icon](#button-with-right-icon) +1. [Disabled Button](#disabled-button) ## Installation @@ -76,3 +77,38 @@ const RightIconButton = () => ( ); export default RightIconButton; ``` + +## Disabled Button + +For a better accessibility (users to have focus on disabled buttons), you should use the aria-disabled attribute instead of the disabled attribute. + +```javascript +const DisabledButton = () => ( + +); +export default DisabledButton; +``` + +Be careful that using the aria-disabled attribute will not disable the button, so you have to handle the disabled state inside your onClick or onSubmit function. + +```javascript +const disabledButton = true; + +
{ + event?.preventDefault(); + if (!disabledButton) { + // call function + } + }}> + + +); +export default DisabledButton; +``` diff --git a/packages/button/src/Button.stories.tsx b/packages/button/src/Button.stories.tsx index 5d6af3a11..cb0f0a86b 100644 --- a/packages/button/src/Button.stories.tsx +++ b/packages/button/src/Button.stories.tsx @@ -76,7 +76,7 @@ ButtonSmallStory.args = { export const ButtonDisabledStory: Story = Template.bind({}); ButtonDisabledStory.storyName = 'Button disabled'; ButtonDisabledStory.args = { - disabled: true, + 'aria-disabled': true, classModifier: 'disabled', children: Button disabled, }; diff --git a/packages/button/src/button.scss b/packages/button/src/button.scss index fb85291c0..70f3e196b 100644 --- a/packages/button/src/button.scss +++ b/packages/button/src/button.scss @@ -83,6 +83,11 @@ $active-sort-table-th: $color-table-sorting !default; } } + &[aria-disabled='true'] { + /* cursor:pointer set by bootstrap reset needs to be ovveride */ + cursor: not-allowed; + } + &--success { background-color: $color-btn-success; box-shadow: inset 0 -3px $color-btn-success-dark;