How to use the @chakra-ui/theme.useColorMode function in @chakra-ui/theme

To help you get started, we’ve selected a few @chakra-ui/theme examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chakra-ui / chakra-ui / packages / chakra-ui / src / CircularProgress / CircularProgress.tsx View on Github external
size = "48px",
    max = 100,
    min = 0,
    isIndeterminate,
    thickness = 0.2,
    value = 0,
    angle = 0,
    capIsRound,
    children,
    trackColor = "gray",
    color = "blue",
    ...rest
  }: CircularProgressProps,
  ref: React.Ref,
) {
  const { colorMode } = useColorMode();

  const _trackColor = { light: `${trackColor}.100`, dark: "whiteAlpha.300" };
  const _color = { light: `${color}.500`, dark: `${color}.200` };

  const {
    rootProps,
    indicatorCircleProps,
    svgProps,
    trackCircleProps,
  } = getComputedProps({
    min,
    max,
    value,
    size,
    angle,
    thickness,
github chakra-ui / chakra-ui / packages / chakra-ui / src / Kbd / Kbd.tsx View on Github external
const Kbd = React.forwardRef(function Kbd(
  props: BoxProps,
  ref: React.Ref,
) {
  const { colorMode } = useColorMode();
  const bg = { light: "gray.100", dark: "whiteAlpha.50" };
  return (
github chakra-ui / chakra-ui / packages / chakra-ui / src / FormErrorMessage / FormErrorMessage.tsx View on Github external
const FormErrorMessage = forwardRef(function FormErrorMessage(
  props: FormErrorMessageProps,
  ref: React.Ref,
) {
  const { colorMode } = useColorMode();
  const formControl = useFormControl(props);

  const color = {
    light: "red.500",
    dark: "red.300",
  };

  if (!formControl.isInvalid) {
    return null;
  }

  return (
github chakra-ui / chakra-ui / packages / chakra-ui / src / InputAddon / InputAddon.tsx View on Github external
const InputAddon = forwardRef(function InputAddon(
  { placement = "left", size = "md", ...props }: InputAddonProps,
  ref: React.Ref,
) {
  const { colorMode } = useColorMode();
  const bg = { dark: "whiteAlpha.300", light: "gray.100" };
  const _placement = {
    left: {
      mr: "-1px",
      roundedRight: 0,
      borderRightColor: "transparent",
    },
    right: {
      order: 1,
      roundedLeft: 0,
      borderLeftColor: "transparent",
    },
  };

  type Placements = keyof typeof _placement;
github chakra-ui / chakra-ui / packages / chakra-ui / src / Alert / styles.ts View on Github external
export function useAlertIconStyle({
  variant,
  color,
}: Required) {
  const { colorMode } = useColorMode();
  if (["left-accent", "top-accent", "subtle"].includes(variant)) {
    let result = {
      light: { color: `${color}.500` },
      dark: { color: `${color}.200` },
    };

    return result[colorMode];
  }
}
github chakra-ui / chakra-ui / packages / chakra-ui / src / Checkbox / Checkbox.tsx View on Github external
isFullWidth,
    size = "md",
    isDisabled,
    isInvalid,
    onChange,
    onBlur,
    onFocus,
    isIndeterminate,
    children,
    iconColor,
    iconSize = "10px",
    ...rest
  }: CheckboxProps,
  ref: React.Ref,
) {
  const { colorMode } = useColorMode();
  const styleProps = checkboxStyles({ color: variantColor, size, colorMode });

  /**
   *
   * TODO: Improve API to be more declarative
   * 
   *   
   *   Welcome home
   * 
   */

  return (
github chakra-ui / chakra-ui / packages / core / src / FormErrorMessage / FormErrorMessage.tsx View on Github external
const FormErrorMessage = forwardRef(function FormErrorMessage(
  props: FormErrorMessageProps,
  ref: React.Ref,
) {
  const { colorMode } = useColorMode();
  const formControl = useFormControl(props);

  const color = {
    light: "red.500",
    dark: "red.300",
  };

  if (!formControl.isInvalid) {
    return null;
  }

  return (
github chakra-ui / chakra-ui / packages / chakra-ui / src / FormHelperText / FormHelperText.tsx View on Github external
const FormHelperText = forwardRef(function FormHelperText<
  P,
  T extends HTMLElement
>(props: TextProps, ref: React.Ref) {
  const { colorMode } = useColorMode();
  const formControl = useFormControl(props);
  const color = { light: "gray.500", dark: "whiteAlpha.600" };

  return (
github chakra-ui / chakra-ui / packages / chakra-ui / src / Avatar / Avatar.tsx View on Github external
export const AvatarBadge = React.forwardRef(function AvatarBadge(
  props: BoxProps,
  ref: React.Ref,
) {
  const { colorMode } = useColorMode();
  const borderColor = { light: "white", dark: "gray.800" };

  return (