1.0.6 • Published 1 year ago

use-attribute v1.0.6

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

use-attribute

To install dependencies:

bun install use-attribute

Usage

import { useAttribute } from "use-attribute";
import clsx from "clsx";
export function Component() {
  const deg = 15;
  const ref = useAttribute<HTMLDivElement>(
    "style",
    [
      `--bg: hsl(${deg}deg 60% 80%)`,
      `--bg-focus: hsl(${deg}deg 70% 80%)`,
      `--bg-hover: hsl(${deg}deg 80% 80%)`,
    ].join("; ")
  );

  return (
    <div
      ref={ref}
      className={clsx(
        "bg-[var(--bg)]",
        "focus:bg-[var(--bg-focus)]",
        "hover:bg-[var(--bg-hover)]"
      )}
    >
      contents
    </div>
  );
}
1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago