GeekyAnts / GeekyAnts/NativeBase

Disabled Button is not WCAG accessible and there is no way to set alternative color with themes other than using opacity.

Open
#5,801 0 comments 0 reactions 0 assignees View on GitHub
bug triage v3
Dominant language
TypeScript
Stars
20.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

### Description

I'm trying to make a WCAG accessible disabled button. There does not appear to be a way to do this using themes other than setting the opacity to a high value which then makes it not look disabled. Is there a way to set the button to a dark grey instead of changing the opacity?

### CodeSandbox/Snack link

https://snack.expo.dev/jHcnUckyx9K5WDm8rnOz1

### Steps to reproduce

![image](https://github.com/GeekyAnts/NativeBase/assets/16007789/8b10e55f-1c2e-4fb2-8347-f2388530c50c)
![image](https://github.com/GeekyAnts/NativeBase/assets/16007789/e4a20e52-e59b-4676-b099-96a67d8314c3)
https://color.adobe.com/create/color-contrast-analyzer
```
import React from 'react';

// 1. Add extendTheme to import
import {
NativeBaseProvider,
extendTheme,
HStack,
Stack,
Button,
Checkbox,
Input,
Center,
Text,
Box,
} from 'native-base';

// 2. Extend the theme to include custom colors, fonts, etc
const newTheme = {
components: {
Button: {
// Can simply pass default props to change default behaviour of components.
baseStyle: {
rounded: 'sm',
width: '90%',
_text: {
fontWeight: 'bold',
textTransform: 'uppercase',
},
_disabled: {
opacity: '50',
color: 'muted.600',// There currently does not seem like a way to set color
},
},
variants: {
solid: {
shadow: 3,
},
outline: {
borderColor: 'primary.500',
},
},
},
},
};
const theme = extendTheme(newTheme);

function App() {
return (

Primary
Hover
Disabled
Outline Variant

Outline Variant

Ghost Variant

Ghost Variant


);
}

function Example() {
return (







Default Unchecked



Default Unchecked Disabled



Default Checked



Default Checked Disabled



);
}

export default () => {
return (



);
};

```

### NativeBase Version

3.4.28

### Platform

- [X] Android
- [ ] CRA
- [X] Expo
- [X] iOS
- [ ] Next

### Other Platform

_No response_

### Additional Information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.