gluestack-ui logo
Get Updates
Prompt to React Native UI
Home
Components
Hooks
Apps
MCP Server
Guides
Home
Overview
IntroductionQuick Start
Getting Started
InstallationTooling SetupVS Code ExtensionsFigma UI KitCLIgluestack-ui-nativewind-utils
Core Concepts
AccessibilityUniversal
Performance
Benchmarks
Theme Configuration
Default TokensCustomizing ThemeDark Mode
Components
All Components
Typography
HeadingrscTextrsc
Layout
BoxrscCenterrscDividerHStackrscVStackrscGridalpha, rsc
Feedback
AlertProgressSpinnerToast
Data Display
BadgeCardrscTablealpha
Forms
ButtonCheckboxFormControlInputLinkPressableRadioSelectSliderSwitchTextarea
Overlay
AlertDialogDrawerMenuModalPopoverPortalTooltip
Disclosure
ActionsheetAccordionBottomSheetalpha
Media And Icons
AvatarImageIconrsc
Others
FabSkeletonalpha, rsc
Hooks
useBreakPointValue
useMediaQuery
Apps
Dashboard App
Kitchensink App
Todo App
Starter Kit
MCP Server
MCP Server
Guides
Recipes
LinearGradient
Tutorials
Building Ecommerce App
More
Upgrade to v2Upgrade to v3FAQsReleasesRoadmapTroubleshootingDiscord FAQs

Button

Discover a powerful button component for React & React Native with customizable size, shape, color, and behavior. Perfect for UI design & seamless user interactions. This is an illustration of Button component.
variant
action
size

Installation

Run the following command:

npx gluestack-ui add button

API Reference

To use this component in your project, include the following import statement in your file.
import {
  Button,
  ButtonText,
  ButtonSpinner,
  ButtonIcon,
  ButtonGroup,
} from '@/components/ui/button';
anatomy-imageanatomy-image
export default () => (
  <ButtonGroup>
    <Button>
      <ButtonText />
      <ButtonSpinner />
      <ButtonIcon />
    </Button>
  </ButtonGroup>
);

Component Props

This section provides a comprehensive reference list for the component props, detailing descriptions, properties, types, and default behavior for easy project integration.

Button

Contains all button related layout style props and actions. It inherits all the properties of React Native's Pressable component.
PropTypeDefaultDescription
isHovered
boolfalseTo manually set hover to the button.
isPressed
boolfalseTo manually set pressable state to the button.
isFocused
boolfalseTo manually set focused state to the button.
isDisabled
boolfalseTo manually set disable to the button.

ButtonText

Contains all text related layout style props and actions. It inherits all the properties of React Native's Text component.

ButtonGroup

Contains all group related layout style props and actions. It inherits all the properties of React Native's View component.
PropTypeDefaultDescription
flexDirection
'row' | 'column' | 'row-reverse' | 'column-reverse''row'Set the direction of Button group to vertical or horizontal
isDisabled
boolfalseWhen true, this will disable all the buttons in a ButtonGroup.
isAttached
boolfalseWhen attached, all buttons will be attached to each other.
reversed
boolfalseTo reverse the order of components.
space
stringmdIt sets the space between different buttons.

ButtonSpinner

Contains all spinner related layout style props and actions. It inherits all the properties of React Native's ActivityIndicator component.

ButtonIcon

Contains all Icon related layout style props and actions. It inherits all the properties of React Native's View component.

Features

  • Keyboard support for actions.
  • Support for hover, focus and active states.
  • Option to add your styles or use the default styles.

Accessibility

We have outlined the various features that ensure the Button component is accessible to all users, including those with disabilities. These features help ensure that your application is inclusive and meets accessibility standards.Adheres to the WAI-ARIA design pattern.

Keyboard

  • Tab
    : Moves focus to the next focusable element.
  • Shift + Tab
    : Moves focus to the previous focusable element.
  • Enter
    : Triggers the button's action.

Screen Reader

  • VoiceOver: When the button is focused, the screen reader will announce the button's label and its current state.

Focus Management

  • The
    onFocus
    and
    onBlur
    props to manage focus states and provide visual cues to users. This is especially important for users who rely on keyboard navigation.

Props

Button component is created using Pressable component from react-native. It extends all the props supported by React Native Pressable, utility props and the props mentioned below.

Button

NameValueDefault
action
primary | secondary | positive | negative | defaultprimary
variant
link | outline | solidsolid
size
xs | sm | md | lg | xlmd
Important Note
Note: These props are exclusively applicable when utilizing the default configuration of gluestack-ui/config. If you are using a custom theme, these props may not be available.

Data Attributes Table

Component receives states as props as boolean values, which are applied as
data-*
attributes. These attributes are then used to style the component via classNames, enabling state-based styling.
StateData AttributeValues
hover
data-hover
true | false
active
data-active
true | false
disabled
data-disabled
true | false
focusVisible
data-focus-visible
true | false

Examples

The Examples section provides visual representations of the different variants of the component, allowing you to quickly and easily determine which one best fits your needs. Simply copy the code and integrate it into your project.

Button with Loading State

A loading button is a type of button component that provides visual feedback to the user during an action that takes some time to complete. It typically displays an animated loading icon or spinner indicating the action is in progress.

Icon Button

A button with an icon integrates a visual symbol within the button component, enhancing its appearance and providing a recognizable and intuitive representation of its associated action or functionality.

Link Button

A button with a link combines the interactive behavior of a button component with the ability to navigate to a specified URL, providing a clickable element for users to access external resources or internal pages.

Button With Icon

The icon component incorporates a button component, combining visual representation with interactive functionality for seamless user interaction.

Button with Full Width

The button with full width component utilizes a button component, expanding its width to occupy the entire available space, creating a visually prominent and easily accessible interface element.
Edit this page on GitHub
Go backTable
Up nextCheckbox
Go backTable
Up nextCheckbox