Props4 / 12
Up next

Default prop values

interface TagProps {
  label: string;
  color?: string;
}

// default a value when the prop is omitted
function Tag({ label, color = "gray" }: TagProps) {
  return <span className={color}>{label}</span>;
}

export default Tag;
What you're solving

give props defaults while destructuring