Link
Inline anchors with underline and plain hover treatments and a themed focus ring.
1234567891011121314151617import { Link } from "#components/ui/ui-sdk/link.tsx";
export function Example() { return ( <> {/* the variant prop resolves through the StyleX recipe and is exposed as a data-variant attribute */} <Link href="/docs" variant="underline">Read the docs</Link>
{/* composition: the render prop replaces the underlying element, e.g. a router's link component */} <Link variant="plain" render={<RouterLink to="/pricing" />}> Pricing </Link> </> );}Variants
Install
1npx stylexblocks add linkSource
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374import * as stylex from "@stylexjs/stylex";import { createComponent } from "#lib/ui-sdk/create-component.tsx";import { defineRecipe } from "#lib/recipe-props.ts";import { colorPalette } from '@stylexblocks/ui/color-palette.stylex.ts'import { semanticRadii } from '@stylexblocks/ui/semantic-tokens/radii.stylex.ts'import { spacing } from '@stylexblocks/ui/tokens/spacing.stylex.ts'
const linkStyles = stylex.create({ base: { display: 'inline-flex', alignItems: 'center', outline: 'none', gap: spacing._1_5, cursor: 'pointer', borderRadius: semanticRadii.control, outlineWidth: { default: null, ':focus': '1px', }, outlineOffset: { default: null, ':focus': '2px', }, outlineStyle: { default: null, ':focus': 'solid', }, outlineColor: { default: null, ':focus': colorPalette.focusRing, }, },})
const linkVariants = stylex.create({ underline: { color: colorPalette.fg, textDecoration: 'underline', textUnderlineOffset: '3px', textDecorationColor: 'currentColor/20', }, plain: { color: colorPalette.fg, textDecoration: { default: null, ':hover': 'underline', }, textUnderlineOffset: { default: null, ':hover': '3px', }, textDecorationColor: { default: null, ':hover': 'currentColor/20', }, },})
export type LinkVariant = keyof typeof linkVariants
/** * Link — recipe and component colocated in one file. The variant prop * resolves mechanically from the axis map. Composition via `render`. */const linkRecipe = defineRecipe({ styles: linkStyles, axes: { variant: linkVariants }, defaultVariants: { variant: "plain" },});
export const Link = createComponent("a", linkRecipe, "Link");
export type LinkProps = React.ComponentProps<typeof Link>;
Examples
Installable blocks built with Link — real use cases, delivered as source you own.
Three-band analytics screen: a multi-series active-sessions chart and KPI sparkline tiles, audience stacked bar cards, and supporting top-routes and top-interactions activity tables.
Minimal, zero-chrome centered credential sign-in form resting directly on the canvas with inline validation, password visibility toggle, inline forgot-password feedback, remember-me persistence, and toast confirmation.
Two-column storefront checkout with express wallets, shipping and billing address fields, selectable delivery cards, auto-formatted card entry with network detection, promo code discounts, gift notes, inline validation, and a sticky collapsible order summary.
Studio project inquiry form with response-time status, three value-proposition cards, validated contact and scope fields, multi-select topic toggles, team-size and budget selects, referral attribution, and a structured submission confirmation view.
Developer documentation hub featuring a searchable hero banner, CLI starter panel, quick-start cards, filterable categorized guide tracks with schematic previews, interactive article preview dialog with copyable code blocks, and live status and changelog links.
Sequential technical quickstart guide featuring breadcrumb navigation, an AI setup prompt card, prerequisites and troubleshooting callouts, synced package-manager and runtime code switchers, checkable step completion progress, onward reading cards, and a responsive sticky table-of-contents rail.
Responsive two-column vendor onboarding and payout profile form with sectioned Fieldset cards, paired field grids, live inline validation, dirty-state tracking, settlement cadence controls, Reset and Save footer actions, and Toaster confirmation feedback.
Centered workspace sign-in card with inline field validation, password visibility toggle, remember-device persistence, Google, GitHub, and passkey provider buttons, and toast feedback.
Split-screen sign-in card pairing an interactive authentication form with validation, password visibility toggle, remember-me control, and social/SAML SSO actions beside an atmospheric architectural brand showcase.
Enterprise single sign-on flow with work-email domain lookup, SAML 2.0 and OIDC identity provider confirmation (Okta, Microsoft Entra ID, Google Workspace), password fallback with inline validation, and toast feedback.
Treasury and infrastructure budget portfolio view with a period switcher, KPI summary tiles, historical reserve value curve, interactive allocation slices, stacked breakdown and budget-vs-actual bars, rate benchmark sparklines, and a filterable, sortable cost-center table.
Engineering work item detail workspace with breadcrumb navigation, editable status, priority, assignee, and sprint properties rail, interactive sub-task checklist with live progress bar, linked pull requests and commits tabs, and a filterable activity timeline with comment composer.
