Span

Span component.

Usage

SpanExample.tsx
  1. 1
  2. 2
  3. 3
<p className="font-serif text-xl">
If I have a component with custom typographical properties and <Span>I need to opt back into my design system's typography</Span>, I can use the <Code>{'<Span />'}</Code> component.
</p>

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

If I have a component with custom typographical properties and I need to opt back into my design system's typography, I can use the <Span /> component.

Features

  • Drop-in replacement for the native <span> 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

span.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 span component.
*/
const Span = forwardRef<HTMLParagraphElement, HTMLAttributes<HTMLSpanElement>>(({ className, ...props }, ref) => <span ref={ref} className={cn('span', className)} {...props} />)
Span.displayName = 'Span'
export { Span }

Styling

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