@chakra-ui/react#ComponentStyleConfig TypeScript Examples

The following examples show how to use @chakra-ui/react#ComponentStyleConfig. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChipInput.tsx    From ke with MIT License 5 votes vote down vote up
ChipInput: ComponentStyleConfig = {
  parts: ['container', 'input', 'chip', 'chipLabel'],
  baseStyle: {
    container: {
      position: 'relative',

      display: 'flex',
      alignItems: 'center',
      flexWrap: 'wrap',
      width: '100%',
      minWidth: 0,

      outline: 0,
      border: '1px solid',
      borderColor: 'inherit',
      bg: 'inherit',
      borderRadius: 'md',

      py: 0.5,
      px: 1,
      minH: 10,

      _hover: {
        borderColor: 'gray.300',
      },
      _readOnly: {
        boxShadow: 'none !important',
        userSelect: 'all',
      },
      _disabled: {
        cursor: 'not-allowed',
      },
      _invalid: {
        borderColor: 'red.500',
        boxShadow: `0 0 0 1px red.500`,
      },
      _focus: {
        zIndex: 1,
        borderColor: 'blue.500',
        boxShadow: `0 0 0 1px blue.500`,
      },
    },
    input: {
      transitionProperty: 'common',
      transitionDuration: 'normal',
      appearance: 'none',
      width: '100%',
      minWidth: 0,
      outline: 0,
    },

    chip: {
      m: 0.5,
      backgroundColor: 'blackAlpha.100',
    },
    chipLabel: {
      color: 'gray.700',
      fontSize: 'md',
      fontWeight: 400,
    },
  },
}
Example #2
Source File: LinkWidget.tsx    From ke with MIT License 5 votes vote down vote up
LinkWidget: ComponentStyleConfig = {
  parts: ['widgetWrapper', 'labelWrapper', 'label', 'description', 'controlWrapper', 'control'],
  baseStyle: {
    widgetWrapper: {
      pt: 1,
    },
    labelWrapper: {
      mt: 5,
      alignItems: 'center',
      flexShrink: 0,
    },
    description: {
      mt: 2,
      fontSize: 'sm',
      lineHeight: '5',
      color: 'gray.500',
    },
  },

  variants: {
    default: {
      controlWrapper: {
        borderWidth: '1px',
        borderRadius: '3px',
        borderColor: '#cbd5e0',
        padding: '5.4px',
      },
      control: {
        color: 'brand.500',
      },
    },
    outline: {
      label: {
        color: 'blackAlpha.600',
      },
      controlWrapper: {
        mt: 0,
        borderWidth: 0,
        padding: 0,
      },
      control: {
        border: '0px',
        padding: 0,
        paddingInlineStart: 0,
        paddingInlineEnd: 0,
        color: 'blue.500',
      },
    },
  },

  defaultProps: {
    variant: 'outline',
  },
}
Example #3
Source File: SelectWidget.tsx    From ke with MIT License 5 votes vote down vote up
SelectWidget = {
  part: ['control', 'dropdownIndicator', 'multiValueContainer', 'multiValueLabel', 'multiValueRemove', 'singleValue'],
  defaultProps: chakraTheme.components.Input.defaultProps,
  variants: {
    outline: (props: StyleFunctionProps) => ({
      control: {
        ...chakraTheme.components.Input.variants.outline(props).field,
        _disabled: {
          opacity: 1,
        },
      },
      singleValue: {
        _disabled: {
          color: 'gray.700',
        },
      },
    }),
    filled: fieldToControlFunction(chakraTheme.components.Input.variants.filled),
    flushed: fieldToControlFunction(chakraTheme.components.Input.variants.flushed),
    unstyled: { control: chakraTheme.components.Input.variants.unstyled.field },
  },
  baseStyle: {
    control: chakraTheme.components.Input.baseStyle.field,
    dropdownIndicator: {
      color: 'gray.700',
      w: 5,
      h: 'auto',
    },
    multiValueContainer: {
      bgColor: 'blackAlpha.100',
      borderRadius: 'md',
      m: '2px',
    },
    multiValueLabel: {
      fontSize: 'md',
      fontWeight: '400',
    },
    multiValueRemove: {
      borderRadius: 'md',
    },
  },
  sizes: Object.fromEntries(Object.entries(sizes).map(([key]) => [key, { control: sizes[key as Sizes] }])),
} as ComponentStyleConfig
Example #4
Source File: ReadOnlyWidget.tsx    From ke with MIT License 4 votes vote down vote up
ReadOnlyWidget: ComponentStyleConfig = {
  parts: ['widgetWrapper', 'labelWrapper', 'label', 'description', 'controlWrapper', 'control'],
  baseStyle: {
    labelWrapper: {
      mt: 6,
      alignItems: 'center',
      flexShrink: 0,
    },
    description: {
      mt: 2,
      fontSize: 'sm',
      lineHeight: '5',
      color: 'gray.500',
    },
    controlWrapper: {
      mt: 2,
    },
    control: {
      display: 'flex',
      flexDirection: 'column',
      alignItems: 'flex-start',
      justifyContent: 'center',
      mt: 1,

      width: '100%',
      minWidth: 0,
      outline: 0,
      position: 'relative',
      transitionProperty: 'common',
      transitionDuration: 'normal',
      border: '1px solid',
      borderColor: 'inherit',
      padding: '5.4px',
      whiteSpace: 'pre-line',
    },
  },
  sizes: {
    lg: {
      control: {
        fontSize: 'lg',
        px: 4,
        minHeight: 12,
        borderRadius: 'md',
      },
    },
    md: {
      control: {
        fontSize: 'md',
        px: 4,
        minHeight: 10,
        borderRadius: 'md',
      },
    },
    sm: {
      control: {
        fontSize: 'sm',
        px: 3,
        minHeight: 8,
        borderRadius: 'sm',
      },
    },
    xs: {
      control: {
        fontSize: 'xs',
        px: 2,
        minHeight: 6,
        borderRadius: 'sm',
      },
    },
  },

  variants: {
    default: {
      control: {
        color: 'black',
      },
    },
    disabled: {
      control: {
        color: 'gray.700',
        borderColor: 'gray.200',
        _hover: {
          borderColor: 'gray.300',
        },
      },
    },
    outline: {
      label: {
        color: 'blackAlpha.600',
      },
      controlWrapper: {
        mt: 0,
      },
      control: {
        minHeight: 0,
        border: '0px',
        padding: 0,
        paddingInlineStart: 0,
        paddingInlineEnd: 0,
      },
    },
  },

  defaultProps: {
    variant: 'outline',
    size: 'md',
  },
}