Headings

@sgroup/tailwind-plugins/headings

.h1 through .h6 classes are available, and should be used when styling headings. This helps keep things consistent across the site. Here's the defaults we apply to headings, which includes setting the:

  • Font family
  • Font weight
  • Leading (line height)
  • Font size

We deliberately keep this lean as in practice setting things like margin, colour and others should be done with utility classes.

Headings

These classes also work on any other element for convenience.

Works on any element

When you want to add things like colour and different styles, you should use utility classes. While you might think every .h1 should be white, this is almost never the case.

Works on any element

Configuration

Configure the @sgroup/tailwind-plugins/headings plugin using theme options.

theme: {
    extend: {
        heading: (theme) => {
            return {
                // Styles for all heading e.g. `.h1, .h2, .h3...`.
                DEFAULT: {
                    fontWeight: theme('fontWeight.bold'),
                },

                // Set the `.h1` font size
                1: {
                    fontSize: theme('fontSize.5xl'),
                    textTransform: 'uppercase',
                },
            };
        },
    },
},