Skip to content

Deprecate Button - #59960

Open
zoontek wants to merge 3 commits into
react:mainfrom
zoontek:deprecate-buttons
Open

zoontek wants to merge 3 commits into
react:mainfrom
zoontek:deprecate-buttons

Conversation

@zoontek

@zoontek zoontek commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

Deprecates Button as part of the effort to keep core lean. It offers very little customization, and you can build an equivalent button with Pressable. It could easily be replaced by a documentation page with some code (ping @Simek).

For an example with a design similar to Button:

import type { ComponentRef, Ref } from "react";
import {
  Platform,
  Pressable,
  StyleSheet,
  Text,
  type ColorValue,
  type PressableAndroidRippleConfig,
  type PressableProps,
} from "react-native";

type ButtonProps = Omit<PressableProps, "children" | "style"> & {
  title: string;
  color?: ColorValue;
  ref?: Ref<ComponentRef<typeof Pressable>>;
};

const androidRipple: PressableAndroidRippleConfig | undefined =
  Platform.OS === "android" ? {} : undefined;

export const Button = ({
  title,
  color,
  disabled: disabledProp,
  importantForAccessibility,
  ...props
}: ButtonProps) => {
  const disabled =
    disabledProp ??
    props["aria-disabled"] ??
    props.accessibilityState?.disabled ??
    false;

  return (
    <Pressable
      accessibilityRole="button"
      android_ripple={androidRipple}
      {...props}
      disabled={disabled}
      importantForAccessibility={
        importantForAccessibility === "no"
          ? "no-hide-descendants"
          : importantForAccessibility
      }
      style={({ pressed }) => [
        styles.button,
        Platform.OS === "android" && color != null && { backgroundColor: color },
        disabled && styles.buttonDisabled,
        pressed && Platform.OS === "ios" && styles.buttonPressed,
      ]}
    >
      <Text
        disabled={disabled}
        style={[
          styles.text,
          Platform.OS === "ios" && color != null && { color },
          disabled && styles.textDisabled,
        ]}
      >
        {Platform.OS === "android" ? title.toUpperCase() : title}
      </Text>
    </Pressable>
  );
};

const styles = StyleSheet.create({
  button: Platform.select({
    ios: {},
    android: {
      elevation: 4,
      backgroundColor: "#2196F3",
      borderRadius: 2,
    },
  }),
  buttonPressed: {
    opacity: 0.2,
  },
  buttonDisabled: Platform.select({
    ios: {},
    android: {
      elevation: 0,
      backgroundColor: "#dfdfdf",
    },
  }),
  text: {
    textAlign: "center",
    margin: 8,
    ...Platform.select({
      ios: {
        color: "#007AFF",
        fontSize: 18,
      },
      android: {
        color: "white",
        fontWeight: "500",
      },
    }),
  },
  textDisabled: Platform.select({
    ios: {
      color: "#cdcdcd",
    },
    android: {
      color: "#a1a1a1",
    },
  }),
});

Changelog:

[GENERAL] [DEPRECATED] - Deprecate Button, build your own button with Pressable instead

Test Plan:

  • deprecated shows a strikethrough on Button in editors.
  • Importing/rendering Button logs the deprecation warning once.
  • yarn flow-check: 0 errors.
  • yarn build-types: ReactNativeApi.d.ts is unchanged.
  • yarn fantom packages/react-native/Libraries/Components/__tests__/Button-itest.js: 10/10 pass.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 12, 2026

@Simek Simek left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🎉

@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Nov 12, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Expo Partner: Expo Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants