✨ Add Link component
Inline link with action (default) and neutral variants, plus an inlineText mode that keeps the underline when embedded in body text. Includes styles and a website example.
This commit is contained in:
1 parent
7b7b13f6e6
commit
39f49989eb
6 files changed
+78
No files matched your search
@@ -12,3 +12,5 @@ export { Accordion, AccordionItem } from "./accordion";
|
||||
export type { AccordionProps, AccordionItemProps } from "./accordion";
|
||||
export { Modal } from "./modal";
|
||||
export type { ModalProps } from "./modal";
|
||||
export { Link } from "./link";
|
||||
export type { LinkProps } from "./link";
|
||||
@@ -0,0 +1,34 @@
|
||||
import { forwardRef } from "react";
|
||||
import type { AnchorHTMLAttributes } from "react";
|
||||
import { cn } from "../util/cn";
|
||||
|
||||
export interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
||||
/**
|
||||
* Link variant.
|
||||
* @default "action"
|
||||
*/
|
||||
variant?: "action" | "neutral";
|
||||
/**
|
||||
* Underlines the link so it reads as part of surrounding body text.
|
||||
* @default false
|
||||
*/
|
||||
inlineText?: boolean;
|
||||
}
|
||||
|
||||
export const Link = forwardRef<HTMLAnchorElement, LinkProps>(function Link(
|
||||
{ variant = "action", inlineText = false, className, ...rest },
|
||||
ref,
|
||||
) {
|
||||
return (
|
||||
<a
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"navds-link",
|
||||
`navds-link--${variant}`,
|
||||
inlineText && "navds-link--inline-text",
|
||||
className,
|
||||
)}
|
||||
{...rest}
|
||||
/>
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,2 @@
|
||||
export { Link } from "./Link";
|
||||
export type { LinkProps } from "./Link";
|
||||
Reference in new issue
Block a user