Debian Codegraph @

node/@patternfly/react-core/src/components/Badge/Badge.tsx

raw
1 import { css } from '@patternfly/react-styles';
2 import styles from '@patternfly/react-styles/css/components/Badge/badge';
3
4 export interface BadgeProps extends React.HTMLProps<HTMLSpanElement> {
5 /** Text announced by screen readers to indicate the current content/status of the badge. */
6 screenReaderText?: string;
7 /** Adds styling to the badge to indicate it has been read */
8 isRead?: boolean;
9 /** Adds styling to the badge to indicate it is disabled */
10 isDisabled?: boolean;
11 /** content rendered inside the Badge */
12 children?: React.ReactNode;
13 /** additional classes added to the Badge */
14 className?: string;
15 }
16
17 export const Badge: React.FunctionComponent<BadgeProps> = ({
18 isRead = false,
19 isDisabled = false,
20 className = '',
21 children = '',
22 screenReaderText,
23 ...props
24 }: BadgeProps) => (
25 <span
26 {...props}
27 className={css(
28 styles.badge,
29 (isRead ? styles.modifiers.read : styles.modifiers.unread) as any,
30 isDisabled && styles.modifiers.disabled,
31 className
32 )}
33 >
34 {children}
35 {screenReaderText && <span className="pf-v6-screen-reader">{screenReaderText}</span>}
36 </span>
37 );
38 Badge.displayName = 'Badge';