MCPcopy
hub / github.com/callstack/react-native-paper / getButtonBackgroundColor

Function getButtonBackgroundColor

src/components/Button/utils.tsx:44–90  ·  view source on GitHub ↗
({
  isMode,
  theme,
  disabled,
  customButtonColor,
}: BaseProps & {
  customButtonColor?: string;
})

Source from the content-addressed store, hash-verified

42};
43
44const getButtonBackgroundColor = ({
45 isMode,
46 theme,
47 disabled,
48 customButtonColor,
49}: BaseProps & {
50 customButtonColor?: string;
51}) => {
52 if (customButtonColor && !disabled) {
53 return customButtonColor;
54 }
55
56 if (theme.isV3) {
57 if (disabled) {
58 if (isMode('outlined') || isMode('text')) {
59 return 'transparent';
60 }
61
62 return theme.colors.surfaceDisabled;
63 }
64
65 if (isMode('elevated')) {
66 return theme.colors.elevation.level1;
67 }
68
69 if (isMode('contained')) {
70 return theme.colors.primary;
71 }
72
73 if (isMode('contained-tonal')) {
74 return theme.colors.secondaryContainer;
75 }
76 }
77
78 if (isMode('contained')) {
79 if (disabled) {
80 return color(theme.dark ? white : black)
81 .alpha(0.12)
82 .rgb()
83 .string();
84 }
85
86 return theme.colors.primary;
87 }
88
89 return 'transparent';
90};
91
92const getButtonTextColor = ({
93 isMode,

Callers 1

getButtonColorsFunction · 0.85

Calls 1

isModeFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…