IconButton
A Jetpack Compose IconButton component for displaying tappable icon buttons.
Android
An icon button component that wraps an icon in a tappable container with different visual variants. See the official Jetpack Compose documentation for more information.
Installation
Terminal
- npx expo install @expo/uiIf you are installing this in an existing React Native app, make sure to install expo in your project.
Usage
Basic icon button
BasicIconButton.tsx
import { Host, IconButton, Icon } from '@expo/ui/jetpack-compose'; export default function BasicIconButton() { return ( <Host matchContents> <IconButton onPress={() => console.log('Pressed')}> <Icon source={require('./assets/favorite.xml')} contentDescription="Favorite" /> </IconButton> </Host> ); }
Variants
Use the variant prop to change the visual style of the button. Available variants are 'default', 'bordered', and 'outlined'.
IconButtonVariants.tsx
import { Host, IconButton, Icon } from '@expo/ui/jetpack-compose'; export default function IconButtonVariants() { return ( <Host matchContents> <IconButton variant="default" onPress={() => console.log('Default')}> <Icon source={require('./assets/favorite.xml')} contentDescription="Default" /> </IconButton> <IconButton variant="bordered" onPress={() => console.log('Bordered')}> <Icon source={require('./assets/favorite.xml')} contentDescription="Bordered" /> </IconButton> <IconButton variant="outlined" onPress={() => console.log('Outlined')}> <Icon source={require('./assets/favorite.xml')} contentDescription="Outlined" /> </IconButton> </Host> ); }
Disabled
Set the disabled prop to prevent interaction.
DisabledIconButton.tsx
import { Host, IconButton, Icon } from '@expo/ui/jetpack-compose'; export default function DisabledIconButton() { return ( <Host matchContents> <IconButton disabled onPress={() => console.log('Pressed')}> <Icon source={require('./assets/favorite.xml')} contentDescription="Favorite" /> </IconButton> </Host> ); }
API
import { IconButton } from '@expo/ui/jetpack-compose';
Component
Type: React.Element<IconButtonProps>
Displays a native button component.
Optional • Type:
ShapeJSXElement