Skip to main content
Brand and assets
Build
Monitor and contribute
/
Component library
  • All components
  • Buttons & actions
  • Forms & inputs
  • Layout & containers
  • Overlays
  • Feedback & status
  • Data display
  • Typography
    • A
    • AnimatedTypography
    • Code
    • Em
    • FormattedText
    • Heading
    • Highlight
    • List
    • Paragraph
    • Strike
    • Strong
    • Text
  • Accessibility
  • Contrib
  • Deprecated
  • Typography
  • A

A

A link to somewhere else, inline in a sentence or on its own. Use `asChild` to pass it a router link.

Health
Component health
Source
View on Github
Design
View Figma
Playground
No Example
Accessibility

compliant

Platform
Universal
  • Overview
  • Props
  • Figma

Basic usage​

I'm a link

Inline usage​

You can use links inline.

Usage with router libraries​

Web: react-router​

It can easily be used with react-router by relying on the asChild prop:

import { A } from "murray";
import { Link } from "react-router-dom";

const Component = () => {
return (
<A asChild>
<Link to="/somepage?id=foo">Go somewhere</Link>
</A>
);
};

Mobile: @react-navigation/native​

It can easily be used with @react-navigation/native by relying on onPress:

import { A } from "murray";

const Component = () => {
const { navigate } = useNavigation();
return <A onPress={() => navigate("SomeScreen", { id: "foo" })}>Go somewhere</A>;
};

Accessibility​

Adheres to the WAI-ARIA Link Pattern

The href, onPress, and asChild props are mutually exclusive by design to ensure proper accessibility semantics. You must provide exactly one of these props.

Edge case: Using href and onPress together

In rare cases where you need both href and onPress (typically for tracking purposes), you can use them together by explicitly disabling TypeScript's type checking with @ts-expect-error:

import { A } from "murray";
import type { GestureResponderEvent } from "react-native";

const Component = () => {
const handleTracking = (e: GestureResponderEvent | KeyboardEvent) => {
// In a web context, Prevent default navigation to ensure onPress completes before page change
// This is critical: without preventDefault, the browser will navigate immediately,
// potentially interrupting your tracking or async operations
if (e && "preventDefault" in e) {
e.preventDefault();
}

// Track link click (this may be async)
analytics.track("link_clicked");

// Optionally navigate programmatically after tracking completes
// window.location.href = "/some-page";
};

return (
<A
href="/some-page"
// @ts-expect-error - href and onPress are mutually exclusive
onPress={handleTracking}
>
Tracked link
</A>
);
};

Important: When using both href and onPress, the onPress handler must intercept the event and call preventDefault() to avoid the page navigation happening before onPress finishes executing. Without this, the browser will navigate immediately, potentially interrupting your tracking or other async operations.

Event types on web:

  • For mouse clicks: GestureResponderEvent (Tamagui wraps the underlying DOM MouseEvent for cross-platform consistency)
  • For keyboard events (Enter key): KeyboardEvent

The GestureResponderEvent type definition doesn't include preventDefault() in its signature, but on web the actual event object does have this method. Always check for preventDefault availability before calling it (as shown in the example above).

Note: This is an edge case typically required only for tracking purposes. In most scenarios, prefer using either href for navigation or onPress for custom actions, but not both.

More details in the dedicated section Anchors.

Playground​

Loading...
tip
This component is universal, its usage is the same in murray and murray/mobile.

A props

NameTypeDefault ValueDescriptionUsage count
aria-labelstringundefined
asChild
5 possibilitiesboolean"web""except-style""except-style-web"undefined
color
4 possibilitiesundefined`$${string}`Variable<any>OpaqueColorValue
disabledbooleanundefinedfalse
downloadstringbooleanundefinedfalse
focusedColorColorTokensundefined
hrefstringundefined
idstringundefined
onFocusundefinedFocusEventHandler<HTMLDivElement>
onPress
2 possibilities((e: GestureResponderEvent | KeyboardEvent) => void)undefined
pressedColorColorTokensundefined
relstringundefined
size
8 possibilitiesundefinednumberVariable<any>"$text100""$text200""$text300""$text400""$text500"
sx
2 possibilitiesundefinedOmit<Omit<TextProps, "fontStyle" | "fontFamily" | "fontWeight">, "hoverStyle" | "pressStyle" | "focusStyle">
targetstringundefined
testIDstringundefinedTest identifier forwarded to the underlying element (e2e selection)
titlestringundefined
unstyledbooleanundefinedfalse
weightTextWeightundefined

Undocumented props

NameTypeDefault ValueDescriptionUsage count
aria-currentany
aria-disabledany
classNameany
cssany
data-testidany
refany
toany

Style API​

Use sx for one-off adjustments. It accepts these style keys:

accessibilityActionsaccessibilityElementsHiddenaccessibilityHintaccessibilityIgnoresInvertColorsaccessibilityLabelaccessibilityLabelledByaccessibilityLanguageaccessibilityLargeContentTitleaccessibilityLiveRegionaccessibilityRespondsToUserInteractionaccessibilityRoleaccessibilityShowsLargeContentVieweraccessibilityStateaccessibilityValueaccessibilityViewIsModalaccessibleadjustsFontSizeToFitalignContentalignItemsalignSelfallowFontScalingandroid_hyphenationFrequencyanimateOnlyanimatePresenceanimationaria-busyaria-checkedaria-disabledaria-expandedaria-hiddenaria-labelaria-labelledbyaria-livearia-modalaria-selectedaria-valuemaxaria-valueminaria-valuenowaria-valuetextasChildaspectRatiobackdropFilterbackfaceVisibilitybackgroundbackgroundAttachmentbackgroundBlendModebackgroundClipbackgroundColorbackgroundImagebackgroundOriginbackgroundPositionbackgroundRepeatbackgroundSizeblockSizeborderBlockColorborderBlockEndColorborderBlockEndStyleborderBlockEndWidthborderBlockStartColorborderBlockStartStyleborderBlockStartWidthborderBlockStyleborderBlockWidthborderBottomColorborderBottomEndRadiusborderBottomLeftRadiusborderBottomRightRadiusborderBottomStartRadiusborderBottomWidthborderColorborderCurveborderEndColorborderEndEndRadiusborderEndStartRadiusborderEndWidthborderImageborderInlineColorborderInlineEndColorborderInlineEndStyleborderInlineEndWidthborderInlineStartColorborderInlineStartStyleborderInlineStartWidthborderInlineStyleborderInlineWidthborderLeftColorborderLeftWidthborderRadiusborderRightColorborderRightWidthborderStartColorborderStartEndRadiusborderStartStartRadiusborderStartWidthborderStyleborderTopColorborderTopEndRadiusborderTopLeftRadiusborderTopRightRadiusborderTopStartRadiusborderTopWidthborderWidthbottomboxShadowboxSizingcaretColorchildrenclassNameclipPathcolorcolumnGapcomponentNamecontaincontainerTypecontentcursordangerouslySetInnerHTMLdataDetectorTypedebugdirectiondisableClassNamedisableOptimizationdisableddisabledStyledisplaydynamicTypeRampelevationellipseellipsizeModeendenterStyleexitStyleexperimental_backgroundImageexperimental_backgroundPositionexperimental_backgroundRepeatexperimental_backgroundSizefilterflexflexBasisflexDirectionflexGrowflexShrinkflexWrapfloatfocusVisibleStylefocusWithinStylefontSizefontVariantfontVariationSettingsforceStylegapgridColumngridColumnEndgridColumnGapgridColumnStartgridRowgridRowEndgridRowGapgridRowStartgridTemplateAreasgridTemplateColumnsgroupheighthitSlophtmlForidimportantForAccessibilityincludeFontPaddinginlineSizeinsetinsetBlockinsetBlockEndinsetBlockStartinsetInlineinsetInlineEndinsetInlineStartisolationjustifyContentleftletterSpacinglineBreakModelineBreakStrategyIOSlineHeightmarginmarginBlockmarginBlockEndmarginBlockStartmarginBottommarginEndmarginHorizontalmarginInlinemarginInlineEndmarginInlineStartmarginLeftmarginRightmarginStartmarginTopmarginVerticalmaskmaskBordermaskBorderModemaskBorderOutsetmaskBorderRepeatmaskBorderSlicemaskBorderSourcemaskBorderWidthmaskClipmaskCompositemaskImagemaskModemaskOriginmaskPositionmaskRepeatmaskSizemaskTypematrixmaxBlockSizemaxFontSizeMultipliermaxHeightmaxInlineSizemaxWidthminBlockSizeminHeightminInlineSizeminWidthminimumFontScalemixBlendModenativeIDnumberOfLinesobjectFitonAccessibilityActiononAccessibilityEscapeonAccessibilityTaponBluronFocusonHoverInonHoverOutonLongPressonMagicTaponMouseDownonMouseEnteronMouseLeaveonMouseUponPressonPressInonPressOutopacityoutlineColoroutlineOffsetoutlineStyleoutlineWidthoverflowoverflowBlockoverflowInlinepaddingpaddingBlockpaddingBlockEndpaddingBlockStartpaddingBottompaddingEndpaddingHorizontalpaddingInlinepaddingInlineEndpaddingInlineStartpaddingLeftpaddingRightpaddingStartpaddingToppaddingVerticalpassThroughperspectivepointerEventspositionpressRetentionOffsetrightrolerotaterotateXrotateYrotateZrotationrowGapscalescaleXscaleYscreenReaderFocusablescrollbarWidthselectableselectionColorseparatorshadowColorshadowOffsetshadowOpacityshadowRadiusskewXskewYspacespaceDirectionstartstylesuppressHighlightingtabIndextagtargettestIDtextAligntextAlignVerticaltextBreakStrategytextDecorationColortextDecorationDistancetextDecorationLinetextDecorationStyletextEmphasistextOverflowtextShadowColortextShadowOffsettextShadowRadiustextTransformtextWrapthemethemeInversethemeShallowtoptouchActiontransformtransformMatrixtransformOrigintransformStyletransitiontranslateXtranslateYuntilMeasureduserSelectverticalAlignwhiteSpacewidthwordWrapwritingDirectionxyzIndex

Each can be overridden per breakpoint with:

$group-focus$group-focusVisible$group-focusWithin$group-hover$group-lg$group-lg-focus$group-lg-focusVisible$group-lg-focusWithin$group-lg-hover$group-lg-press$group-ltLg$group-ltLg-focus$group-ltLg-focusVisible$group-ltLg-focusWithin$group-ltLg-hover$group-ltLg-press$group-ltMd$group-ltMd-focus$group-ltMd-focusVisible$group-ltMd-focusWithin$group-ltMd-hover$group-ltMd-press$group-ltSm$group-ltSm-focus$group-ltSm-focusVisible$group-ltSm-focusWithin$group-ltSm-hover$group-ltSm-press$group-ltVs$group-ltVs-focus$group-ltVs-focusVisible$group-ltVs-focusWithin$group-ltVs-hover$group-ltVs-press$group-ltXl$group-ltXl-focus$group-ltXl-focusVisible$group-ltXl-focusWithin$group-ltXl-hover$group-ltXl-press$group-ltXxl$group-ltXxl-focus$group-ltXxl-focusVisible$group-ltXxl-focusWithin$group-ltXxl-hover$group-ltXxl-press$group-md$group-md-focus$group-md-focusVisible$group-md-focusWithin$group-md-hover$group-md-press$group-press$group-sm$group-sm-focus$group-sm-focusVisible$group-sm-focusWithin$group-sm-hover$group-sm-press$group-vs$group-vs-focus$group-vs-focusVisible$group-vs-focusWithin$group-vs-hover$group-vs-press$group-xl$group-xl-focus$group-xl-focusVisible$group-xl-focusWithin$group-xl-hover$group-xl-press$group-xs$group-xs-focus$group-xs-focusVisible$group-xs-focusWithin$group-xs-hover$group-xs-press$group-xxl$group-xxl-focus$group-xxl-focusVisible$group-xxl-focusWithin$group-xxl-hover$group-xxl-press$lg$ltLg$ltMd$ltSm$ltVs$ltXl$ltXxl$md$platform-android$platform-ios$platform-native$platform-web$sm$vs$xl$xs$xxl
Edit this page
Previous
Timeline
Next
AnimatedTypography
  • Basic usage
  • Inline usage
  • Usage with router libraries
    • Web: react-router
    • Mobile: @react-navigation/native
  • Accessibility
  • Playground