IconButton consists of the Button component. It is generally used to make an Icon pressable.
const Example = () => {
return <IconButton icon={<Icon as={Entypo} name="emoji-happy" />} borderRadius="full" _icon={{
color: 'coolGray.50',
size: 'md'
}} _hover={{
bg: 'coolGray.800:alpha.20'
}} _pressed={{
bg: 'coolGray.800:alpha.20',
_icon: {
name: 'emoji-flirt'
},
_ios: {
_icon: {
size: '2xl'
}
}
}} _ios={{
_icon: {
size: '2xl'
}
}} />;
};
const Example = () => {
return <Box alignItems="center">
<IconButton icon={<Icon as={Entypo} name="emoji-happy" />} borderRadius="full" _icon={{
color: "orange.500",
size: "md"
}} _hover={{
bg: "orange.600:alpha.20"
}} _pressed={{
bg: "orange.600:alpha.20",
_icon: {
name: "emoji-flirt"
},
_ios: {
_icon: {
size: "2xl"
}
}
}} _ios={{
_icon: {
size: "2xl"
}
}} />
</Box>;
};
const Example = () => {
return <Center>
<VStack space={4} alignItems="center">
{["xs", "sm", "md", "lg"].map(size => <IconButton size={size} variant="solid" _icon={{
as: MaterialIcons,
name: "menu"
}} />)}
</VStack>
</Center>;
};
const Example = () => {
return <Center>
<VStack space={4} alignItems="center">
{["outline", "solid", "ghost"].map(variant => <IconButton colorScheme="indigo" key={variant} variant={variant} _icon={{
as: AntDesign,
name: "search1"
}} />)}
</VStack>
</Center>;
};
IconButton implements
,
,
,
,
,
,
,
,
,
,
,
The color of the radio when it's checked. This should be one of the color keys in the theme (e.g."green", "red").
The variant of the button style to use.
Type: ResponsiveValue<"link" | "subtle" | "solid" | "ghost" | "outline" | (string & {}) | "unstyled">
The size of the button.
Type: ThemeComponentSizeType<"IconButton"> & ThemeComponentSizeType<"Icon">
If true, the button will be disabled.
The icon to be used. Refer to the Icon section of the docs for the available icon options.
Props to be passed to the icon used inside of IconButton.
Type: Partial<IIconProps>
Style props to be applied when hovered
Type: Omit<Partial<IIconButtonProps>, "_hover">
Style props to be applied when pressed
Type: Omit<Partial<IIconButtonProps>, "_pressed">
Style props to be applied when focus
Type: Omit<Partial<IIconButtonProps>, "_focus">
NativeBase ships with a default theme for each component. Check out the default theme of the iconButton
.
Info:
We can easily extend the iconButton component theme using extendTheme function as described in the documentation .Use accessibilityLabel for labelling icon buttons to make sure it's announced by screen reader devices.
IconButton has a
role set to
.