addons/components/Badge.tsxblame
View source
b69ab311/**
b69ab312 * Copyright (c) Meta Platforms, Inc. and affiliates.
b69ab313 *
b69ab314 * This source code is licensed under the MIT license found in the
b69ab315 * LICENSE file in the root directory of this source tree.
b69ab316 */
b69ab317
b69ab318import type {ReactNode} from 'react';
b69ab319import type {ReactProps} from './utils';
b69ab3110
b69ab3111import * as stylex from '@stylexjs/stylex';
b69ab3112
b69ab3113const styles = stylex.create({
b69ab3114 badge: {
b69ab3115 display: 'inline-flex',
b69ab3116 alignItems: 'center',
b69ab3117 boxSizing: 'border-box',
b69ab3118 backgroundColor: 'var(--badge-background)',
b69ab3119 border: '1px solid var(--button-border)',
b69ab3120 borderRadius: '11px',
b69ab3121 color: 'var(--badge-foreground)',
b69ab3122 padding: '3px 6px',
b69ab3123 fontFamily: 'var(--font-family)',
b69ab3124 fontSize: '11px',
b69ab3125 minHeight: '18px',
b69ab3126 minWidth: '18px',
b69ab3127 lineHeight: '16px',
b69ab3128 height: '16px',
b69ab3129
b69ab3130 textOverflow: 'ellipsis',
b69ab3131 maxWidth: '150px',
b69ab3132 whiteSpace: 'nowrap',
b69ab3133 overflow: 'hidden',
b69ab3134 },
b69ab3135});
b69ab3136
b69ab3137export function Badge({
b69ab3138 xstyle,
b69ab3139 ...rest
b69ab3140}: {children: ReactNode; xstyle?: stylex.StyleXStyles} & ReactProps<HTMLSpanElement>) {
b69ab3141 return <span {...stylex.props(styles.badge, xstyle)} {...rest} />;
b69ab3142}