import React from "react"; import { CHIP_COLORS, cls, getColorSchemeForKey } from "../util"; export type ChipColorScheme = { color: string; text: string; } export type ChipColorKey = keyof typeof CHIP_COLORS; export interface ChipProps { className?: string; children: React.ReactNode; size?: "small" | "medium" | "large"; colorScheme?: ChipColorScheme | ChipColorKey; error?: boolean; outlined?: boolean; onClick?: () => void; icon?: React.ReactNode; style?: React.CSSProperties; } const sizeClassNames = { small: "px-2 py-0.5 text-sm", medium: "px-3 py-1 text-sm", large: "px-4 py-1.5 text-sm" } /** * @group Preview components */ export const Chip = React.forwardRef(function Chip({ children, colorScheme, error, outlined, onClick, icon, size = "large", className, style }: ChipProps, ref) { const usedColorScheme = typeof colorScheme === "string" ? getColorSchemeForKey(colorScheme) : colorScheme; return (
{children} {icon}
); });