An open source design system that's fully customizable and agent ready
TypeScript
docs(core): document Link type=inherit for inline links (#2927) (#3262)
Durvesh Pilankar47b8395bd8a6
diff --git a/.changeset/link-type-inherit-docs.md b/.changeset/link-type-inherit-docs.mdnew file mode 100644index 0000000000..a6311548ab--- /dev/null+++ b/.changeset/link-type-inherit-docs.md@@ -0,0 +1,6 @@+---+'@astryxdesign/core': patch+---++[docs] Link: document `type="inherit"` for inline links. The value was already supported (forwarded to `Text`, which renders `font-size`/`line-height: inherit`), but undocumented — clarified the `type` prop JSDoc, added an inline-link example, and added regression tests covering the inherit/default-body behavior (#2927)+@durvesh1992diff --git a/packages/core/src/Link/Link.test.tsx b/packages/core/src/Link/Link.test.tsxindex f6e5ddb698..c8d823a909 100644--- a/packages/core/src/Link/Link.test.tsx+++ b/packages/core/src/Link/Link.test.tsx@@ -120,6 +120,24 @@ describe('Link', () => {expect(screen.getByRole('link')).toBeInTheDocument();});+ it('defaults the inner text type to body', () => {+ render(<Link href="/test">Body link</Link>);+ expect(screen.getByText('Body link')).toHaveClass('astryx-text', 'body');+ });++ it('forwards type="inherit" so the link adopts the surrounding text type', () => {+ render(+ <Link href="/test" type="inherit">+ Inline link+ </Link>,+ );+ // The inner Text renders with the `inherit` type, so font-size/line-height+ // inherit from the surrounding text rather than imposing the body type.+ const text = screen.getByText('Inline link');+ expect(text).toHaveClass('astryx-text', 'inherit');+ expect(text).not.toHaveClass('body');+ });+it('applies hasUnderline style when true', () => {render(<Link href="/test" hasUnderline>diff --git a/packages/core/src/Link/Link.tsx b/packages/core/src/Link/Link.tsxindex 1938921cc6..7966d07d9f 100644--- a/packages/core/src/Link/Link.tsx+++ b/packages/core/src/Link/Link.tsx@@ -203,6 +203,10 @@ export interface LinkProps extends BaseProps<isStandalone?: boolean;/*** Semantic text type for Text. Determines base typography.+ *+ * Use `type="inherit"` for inline links inside an existing `Text` element so+ * the link adopts the surrounding text's size and line-height instead of+ * imposing its own (e.g. a link within a `large` paragraph).* @default 'body'*/type?: TextType;@@ -248,6 +252,11 @@ export interface LinkProps extends BaseProps<* <Link href="/settings" color="secondary">Settings</Link>* <Link href="/privacy" hasUnderline>Privacy Policy</Link>* <Link label="Close dialog" href="/home"><Icon icon="x" /></Link>+ *+ * // Inline link inside text — inherits the surrounding type/size:+ * <Text type="large">+ * Read our <Link href="/terms" type="inherit">terms</Link> first.+ * </Text>* ```*/export function Link({