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

package.src.components.Nav.NavGroup.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 styles from '@patternfly/react-styles/css/components/Nav/nav';
import { css } from '@patternfly/react-styles';
import { getUniqueId } from '../../helpers/util';

export interface NavGroupProps extends React.HTMLProps {
  /** Title shown for the group */
  title?: string;
  /** Anything that can be rendered inside of the group */
  children?: React.ReactNode;
  /** Additional classes added to the container */
  className?: string;
  /** Identifier to use for the section aria label */
  id?: string;
}

export const NavGroup: React.FunctionComponent = ({
  title,
  children = null,
  className = '',
  id = getUniqueId(),
  ...props
}: NavGroupProps) => {
  if (!title && !props['aria-label']) {
    // eslint-disable-next-line no-console
    console.warn("For accessibility reasons an aria-label should be specified on nav groups if a title isn't");
  }

  const labelledBy = title ? id : undefined;

  return (
    
{title && (

{title}

)}
    {children}
); }; NavGroup.displayName = 'NavGroup';




© 2015 - 2024 Weber Informatics LLC | Privacy Policy