B

Bold component.

Usage

BExample.tsx
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
<P>
The two most popular science courses offered by the school are <B>chemistry</B>
(the study of chemicals and the composition of substances) and <B>physics</B>
(the study of the nature and properties of matter and energy).
</P>

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

The two most popular science courses offered by the school are chemistry (the study of chemicals and the composition of substances) and physics (the study of the nature and properties of matter and energy).

Notice how the <B> element is used to draw attention to text without indicating that it's more important.

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

The <b> HTML element is used to draw the reader's attention to the element's contents, which are not otherwise granted special importance. This was formerly known as the Boldface element, and most browsers still draw the text in boldface. However, you should not use <b> for styling text because that's a job for CSS and you should not use <b> for granting importance or stress emphasis because that's a job for the <strong> and <em> tags, respectively.

<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.

Features

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

Source

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

Styling

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