Expand commentComment on line R9Resolved

Button link

Button link is a navigation element that combines the visual appearance of a button with the native behavior of a regular link. It allows users to navigate to another page, resource, or destination through a more prominent, button-like interface.

Props

NameTypeDescriptionDefault
ariaLabelstringText to be used as aria-label for the button link. If provided, it takes precedence over the label as the accessible name. It will be required if no label or title are provided.-
disabledbooleanIf true, the link will be disabled.false
Required
href
stringPage to be opened when the user clicks on the link.-
iconstring | (React.ReactNode & React.SVGProps <SVGSVGElement>)Material Symbol name or SVG element as the icon that will be placed next to the link text. When using Material Symbols, replace spaces with underscores. By default they are outlined if you want it to be filled prefix the symbol name with "filled_". Required if no label is provided.-
iconPosition'before' | 'after'Indicates the position of the icon in the component.'before'
labelstringText to be placed in the button link. Required if no icon is provided.-
mode'primary' | 'secondary' | 'tertiary'The available button link modes.'primary'
newWindowbooleanIf true, the page is opened in a new browser tab.false
onClick(event: React.MouseEvent<HTMLAnchorElement>) => voidIf defined, the link will be displayed as a button. This function will be called when the user clicks the link.-
refReact.Ref<HTMLAnchorElement>Ref of the link element.-
size{ height: 'small' | 'medium' | 'large'; width: 'small' | 'medium' | 'large' | 'fillParent' | 'fitContent' }Object used to define the dimensions of the button in terms of height and width. { height: 'large'; width: 'fitContent' }
tabIndexnumberValue of the tabindex attribute.0
titlestringText to be displayed as a tooltip when hovering over the link. If there is no label, the title will be used as the aria-label.-

Examples

Basic usage

() => {
  return (
    <DxcInset space="var(--spacing-padding-xl)">
      <DxcButtonLink label="Link" href="#" />
    </DxcInset>
  );
}

Icons

() => {
  return (
    <DxcInset space="var(--spacing-padding-xl)">
      <DxcFlex gap="var(--spacing-gap-l)">
        <DxcButtonLink href="#" icon="volunteer_activism" label="Donate" />
        <DxcButtonLink href="#" icon="filled_volunteer_activism" mode="secondary" title="Donate" />
      </DxcFlex>
    </DxcInset>
  );
}

Modes

() => {
  return (
    <DxcInset space="var(--spacing-padding-xl)">
      <DxcFlex gap="var(--spacing-gap-l)">
        <DxcButtonLink href="#" label="Primary" />
        <DxcButtonLink href="#" mode="secondary" label="Secondary" />
        <DxcButtonLink href="#" mode="tertiary" label="Tertiary" />
      </DxcFlex>
    </DxcInset>
  );
}

Size

() => {
  return (
    <DxcInset space="var(--spacing-padding-xl)">
    <DxcFlex gap="var(--spacing-gap-l)" direction="column">
        <DxcFlex gap="var(--spacing-gap-l)">
          <DxcButtonLink href="#" icon="person" semantic="default" size={{ height: "small", width: "small" }} />
          <DxcButtonLink href="#" label="Submit" size={{ height: "small", width: "medium" }} />
          <DxcButtonLink href="#" label="Search" icon="search" size={{ height: "small", width: "large" }} />
          <DxcButtonLink href="#" label="Edit" size={{ height: "small", width: "fitContent" }} />
          <DxcButtonLink href="#" label="Learn more" size={{ height: "small", width: "fillParent" }} />
        </DxcFlex>
        <DxcFlex gap="var(--spacing-gap-l)">
          <DxcButtonLink href="#" icon="person" semantic="default" size={{ height: "medium", width: "small" }} />
          <DxcButtonLink href="#" label="Submit" size={{ height: "medium", width: "medium" }} />
          <DxcButtonLink href="#" label="Search" icon="search" size={{ height: "medium", width: "large" }} />
          <DxcButtonLink href="#" label="Edit" size={{ height: "medium", width: "fitContent" }} />
          <DxcButtonLink href="#" label="Learn more" size={{ height: "medium", width: "fillParent" }} />
        </DxcFlex>
        <DxcFlex gap="var(--spacing-gap-l)">
          <DxcButtonLink href="#" icon="person" semantic="default" size={{ height: "large", width: "small"}} />
          <DxcButtonLink href="#" label="Submit" size={{ height: "large", width: "medium" }} />
          <DxcButtonLink href="#" label="Search" icon="search" size={{ height: "large", width: "large" }} />
          <DxcButtonLink href="#" label="Edit" size={{ height: "large", width: "fitContent" }} />
          <DxcButtonLink href="#" label="Learn more" size={{ height: "large", width: "fillParent" }} />
        </DxcFlex>
      </DxcFlex>
    </DxcInset>
  );
}