Develop ultra fast with Prismane 🎉

usePrismaneColor

usePrismaneColor hook provides a simple way to handle colors and custom color styles.

Import

import { usePrismaneColor } from "@prismane/core";

Usage

function Demo() {
  const { getColor } = usePrismaneColor();

  return (
    <>
      <Box w={fr(20)} h={fr(20)} bg={getColor("primary")} />
      <Box w={fr(20)} h={fr(20)} bg={getColor("primary", 200)} />
    </>
  );
}

Parsing Custom Color Styles

function Demo() {
  const { getColorStyle } = usePrismaneColor();

  return (
    <Box
      w={fr(20)}
      h={fr(20)}
      bdw={1}
      sx={{
        borderColor: getColorStyle(["base", { hover: "primary" }]),
      }}
    />
  );
}

API

Return Value

NameTypeDescription
getColor() => stringA function that parses the color into a hex code.
getColorStyle() => stringA function that parses the color for the sx prop.

getColor's Parameters

NameTypeDescriptionDefault
colorstringThe color that is wanted.-
shadenumberThe shade of the given color that is wanted.500

getColor's Return Value

NameTypeDescription
colorstringThe parsed color.