Strong

Strong component.

Usage

StrongExample.tsx
  1. 1
  2. 2
  3. 3
<P>
<Strong>Warning!</Strong> This is <Strong>very dangerous</Strong>.
</P>

Here's the <Strong /> component in action.

Warning! This is very dangerous.

Notice that <strong> tags will go inside <p> tags and inherit whatever typographical attributes that paragraph has.

<b> vs <strong>

It is often confusing to new developers why there are so many ways to express the same thing on a rendered website. <b> and <strong> are perhaps one of the most common sources of confusion, causing developers to ask "Should I use <b> or <strong>? Don't they both do the same thing?"

Not exactly. The <strong> element is for content that is of greater importance, while the <b> element is used to draw attention to text without indicating that it's more important.

It may help to realize that both are valid and semantic elements in HTML and that it's a coincidence that they both have the same default styling (boldface) in most browsers (although some older browsers actually underline <strong>). Each element is meant to be used in certain types of scenarios, and if you want to bold text for decoration, you should instead actually use the CSS font-weight property.

The intended meaning or purpose of the enclosed text should be what determines which element you use. Communicating meaning is what semantics are all about.

<em> vs <strong>

Adding to the confusion is the fact that while HTML 4 defined <strong> as indicating a stronger emphasis, HTML 5 defines <strong> as representing "strong importance for its contents." This is an important distinction to make.

While <em> is used to change the meaning of a sentence as spoken emphasis does ("I love carrots" vs. "I love carrots"), <strong> is used to give portions of a sentence added importance (e.g., "Warning! This is very dangerous.") Both <strong> and <em> can be nested to increase the relative degree of importance or stress emphasis, respectively.

Features

  • Drop-in replacement for the native <strong> element.
  • Opts-in to your design system's typographic styles.

Parts and their API

The tracking's default value depends on the size prop and is controlled through CSS variables: check out the styling section.

Source

strong.tsx
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
import { forwardRef, type HTMLAttributes } from 'react'
import { cn } from '#app/utils/tailwind-merge.ts'
/**
* A strong component.
*/
const Strong = forwardRef<HTMLElement, HTMLAttributes<HTMLElement>>(({ className, ...props }, ref) => <strong ref={ref} className={cn('strong', className)} {...props} />)
Strong.displayName = 'Strong'
export { Strong }

Styling

tailwind.css
  1. 1
  2. 2
  3. 3
.strong {
@apply font-sans font-bold;
}