✨ Add Button, BodyShort and Heading to @navikt/ds-react

forwardRef-based components with navds-* classnames composed via a small
local cn() utility. Adds shared tsconfig.base.json and truncate modifier
for BodyShort.
This commit is contained in:
Aksel Mini committed 2026-08-10 11:00:00 +02:00
1 parent b4930f754e
commit 559fd2b971
12 files changed
+164

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
import { forwardRef } from "react";
import type { ButtonHTMLAttributes } from "react";
import { cn } from "../util/cn";
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
/**
* Visual variant.
* @default "primary"
*/
variant?: "primary" | "secondary" | "tertiary" | "danger";
/**
* Button size.
* @default "medium"
*/
size?: "medium" | "small";
}
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(function Button(
{ variant = "primary", size = "medium", type = "button", className, ...rest },
ref,
) {
return (
<button
ref={ref}
type={type}
className={cn("navds-button", `navds-button--${variant}`, `navds-button--${size}`, className)}
{...rest}
/>
);
});
+2
View File
@@ -0,0 +1,2 @@
export { Button } from "./Button";
export type { ButtonProps } from "./Button";