IconButtonLink is mainly used as navigational element.
Props
Usage guidelines
See IconButton for usage guidelines.
Localization
Be sure to localize all text strings. Note that localization can lengthen text by 20 to 30 percent.
import { DefaultLabelProvider, Flex, IconButtonLink } from 'gestalt'; export default function Example() { return ( <DefaultLabelProvider labels={{ Link: { accessibilityNewTabLabel: 'Öffnet eine neue Browser-Registerkarte.', accessibilityDownloadLabel: 'Es lädt eine Datei herunter.', }, }} > <Flex alignItems="center" height="100%" justifyContent="center" width="100%" > <IconButtonLink accessibilityLabel="" href="#" icon="visit" onClick={({ event, dangerouslyDisableOnNavigation }) => { event.preventDefault(); dangerouslyDisableOnNavigation(); }} target="blank" tooltip={{ text: 'Besuchen Sie Pinterest' }} /> </Flex> </DefaultLabelProvider> ); }
Variants
See IconButton for more variants.
External handlers
IconButtonLink consumes external handlers from GlobalEventsHandlerProvider.
Handlers:
- onNavigation: executed when IconButtonLink is clicked
See GlobalEventsHandlerProvider for more information.
Focus ring on dark backgrounds
IconButtonLink can be used on dark backgrounds. The focus ring is visible on dark backgrounds to ensure accessibility.
import { Box, Flex, IconButtonLink } from 'gestalt'; export default function Example() { return ( <Flex gap={6}> <Flex direction="column" gap={6}> <Flex direction="column"> <Box alignItems="center" dangerouslySetInlineStyle={{ __style: { backgroundImage: 'url("https://i.ibb.co/rcdDzVh/image.png")', }, }} display="flex" height="100%" justifyContent="center" padding={8} > <IconButtonLink accessibilityLabel="Go to Pinterest" focusColor="lightBackground" href="www.pinterest.com" icon="visit" iconColor="red" tooltip={{ accessibilityLabel: 'Go to Pinterest', text: 'Go to Pinterest', idealDirection: 'up', }} /> </Box> focusColor="lightBackground" </Flex> <Flex direction="column"> <Box alignItems="center" dangerouslySetInlineStyle={{ __style: { backgroundImage: 'url("https://i.ibb.co/DC0sQrx/image.png")', }, }} display="flex" height="100%" justifyContent="center" padding={8} > <IconButtonLink accessibilityLabel="Go to Pinterest" focusColor="darkBackground" href="www.pinterest.com" icon="visit" iconColor="red" tooltip={{ accessibilityLabel: 'Go to Pinterest', text: 'Go to Pinterest', idealDirection: 'up', }} /> </Box> focusColor="darkBackground" </Flex> </Flex> <Flex direction="column" gap={6}> <Flex direction="column"> <Box alignItems="center" dangerouslySetInlineStyle={{ __style: { backgroundImage: 'url("https://i.ibb.co/rcdDzVh/image.png")', }, }} display="flex" height="100%" justifyContent="center" padding={8} > <IconButtonLink accessibilityLabel="Go to Pinterest" focusColor="lightBackground" href="www.pinterest.com" icon="visit" iconColor="red" tooltip={{ accessibilityLabel: 'Go to Pinterest', text: 'Go to Pinterest', idealDirection: 'up', }} /> </Box> focusColor="lightBackground" </Flex> <Flex direction="column"> <Box alignItems="center" dangerouslySetInlineStyle={{ __style: { backgroundImage: 'url("https://i.ibb.co/DC0sQrx/image.png")', }, }} display="flex" height="100%" justifyContent="center" padding={8} > <IconButtonLink accessibilityLabel="Go to Pinterest" focusColor="darkBackground" href="www.pinterest.com" icon="visit" iconColor="red" tooltip={{ accessibilityLabel: 'Go to Pinterest', text: 'Go to Pinterest', idealDirection: 'up', }} /> </Box> focusColor="darkBackground" </Flex> </Flex> </Flex> ); }
Component quality checklist
Quality item | Status | Status description |
---|---|---|
Figma Library | Ready | Component is available in Figma for web and mobile web. |
Responsive Web | Ready | Component responds to changing viewport sizes in web and mobile web. |
Internal documentation
Related
GlobalEventsHandlerProvider
GlobalEventsHandlerProvider allows external link navigation control across all children components with link behavior.
See
GlobalEventsHandlerProvider to learn more about link navigation.