All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.src.components.Card.CardTitle.tsx Maven / Gradle / Ivy

Go to download

This library provides a set of common React components for use with the PatternFly reference implementation.

The newest version!
import * as React from 'react';
import { css } from '@patternfly/react-styles';
import styles from '@patternfly/react-styles/css/components/Card/card';
import { CardContext } from './Card';

export interface CardTitleProps extends React.HTMLProps {
  /** Content rendered inside the CardTitle */
  children?: React.ReactNode;
  /** Additional classes added to the CardTitle */
  className?: string;
  /** Sets the base component to render. defaults to div */
  component?: keyof JSX.IntrinsicElements;
}

export const CardTitle: React.FunctionComponent = ({
  children,
  className,
  component = 'div',
  ...props
}: CardTitleProps) => {
  const { cardId, registerTitleId } = React.useContext(CardContext);
  const Component = component as any;
  const titleId = cardId ? `${cardId}-title` : '';

  React.useEffect(() => {
    registerTitleId(titleId);

    return () => registerTitleId('');
  }, [registerTitleId, titleId]);

  return (
    
{children}
); }; CardTitle.displayName = 'CardTitle';




© 2015 - 2024 Weber Informatics LLC | Privacy Policy